diff options
author | Fam Zheng <famz@redhat.com> | 2017-08-23 21:42:40 +0800 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2017-08-23 10:21:55 -0500 |
commit | ca2e214411598154d6b36ea70ba7900fbaeedc93 (patch) | |
tree | a93775293c329b048a944b4738773680adf8ed90 /block | |
parent | c16de8f59a2bcbe2dc037524cc648de896f581a4 (diff) | |
download | qemu-ca2e214411598154d6b36ea70ba7900fbaeedc93.zip qemu-ca2e214411598154d6b36ea70ba7900fbaeedc93.tar.gz qemu-ca2e214411598154d6b36ea70ba7900fbaeedc93.tar.bz2 |
block-backend: Allow more "can inactivate" cases
These two conditions corresponds to mirror job's source and target,
which need to be allowed as they are part of the non-shared storage
migration workflow: failing to inactivate either will result in a
failure during migration completion.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170823134242.12080-3-famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[eblake: improve comment grammar]
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/block-backend.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index a3984d2..1031742 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -70,6 +70,7 @@ struct BlockBackend { int quiesce_counter; VMChangeStateEntry *vmsh; + bool force_allow_inactivate; }; typedef struct BlockBackendAIOCB { @@ -192,17 +193,28 @@ static void blk_root_activate(BdrvChild *child, Error **errp) } } +void blk_set_force_allow_inactivate(BlockBackend *blk) +{ + blk->force_allow_inactivate = true; +} + static bool blk_can_inactivate(BlockBackend *blk) { - /* 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 it is a guest device, inactivate is ok. */ if (blk->dev || blk_name(blk)[0]) { return true; } - return false; + /* Inactivating means no more writes to the image can be done, + * even if those writes would be changes invisible to the + * guest. For block job BBs that satisfy this, we can just allow + * it. This is the case for mirror job source, which is required + * by libvirt non-shared block migration. */ + if (!(blk->perm & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED))) { + return true; + } + + return blk->force_allow_inactivate; } static int blk_root_inactivate(BdrvChild *child) |