mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-30 05:21:55 -06:00
block: Drop permissions when migration completes
With image locking, permissions affect other qemu processes as well. We want to be sure that the destination can run, so let's drop permissions on the source when migration completes. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
4417ab7adf
commit
cfa1a5723f
3 changed files with 40 additions and 4 deletions
|
@ -156,6 +156,30 @@ static void blk_root_activate(BdrvChild *child, Error **errp)
|
|||
}
|
||||
}
|
||||
|
||||
static int blk_root_inactivate(BdrvChild *child)
|
||||
{
|
||||
BlockBackend *blk = child->opaque;
|
||||
|
||||
if (blk->disable_perm) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Only inactivate BlockBackends for guest devices (which are inactive at
|
||||
* this point because the VM is stopped) and unattached monitor-owned
|
||||
* BlockBackends. If there is still any other user like a block job, then
|
||||
* we simply can't inactivate the image. */
|
||||
if (!blk->dev && !blk->name[0]) {
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
blk->disable_perm = true;
|
||||
if (blk->root) {
|
||||
bdrv_child_try_set_perm(blk->root, 0, BLK_PERM_ALL, &error_abort);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const BdrvChildRole child_root = {
|
||||
.inherit_options = blk_root_inherit_options,
|
||||
|
||||
|
@ -168,6 +192,7 @@ static const BdrvChildRole child_root = {
|
|||
.drained_end = blk_root_drained_end,
|
||||
|
||||
.activate = blk_root_activate,
|
||||
.inactivate = blk_root_inactivate,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue