Message ID | 1469602913-20979-2-git-send-email-xiecl.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Jul 27, 2016 at 03:01:42PM +0800, Changlong Xie wrote: > From: Wen Congyang <wency@cn.fujitsu.com> > > Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> > Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com> > Signed-off-by: Wang WeiWei <wangww.fnst@cn.fujitsu.com> > --- > block.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[I erroneously gave a Tested-by to the next patch (02/12) in this series, instead of this one.] On Wed, Jul 27, 2016 at 03:01:42PM +0800, Changlong Xie wrote: > From: Wen Congyang <wency@cn.fujitsu.com> > > Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> > Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com> > Signed-off-by: Wang WeiWei <wangww.fnst@cn.fujitsu.com> > --- > block.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) Tested-by: Kashyap Chamarthy <address@hidden> Test case: Without this patch applied ========================== Create an empty target image: $ qemu-img create -f qcow2 target.qcow2 1G $ ./qmp-shell -v -p ./qmp-sock (QEMU) blockdev-add options={"id":"drive-ide1-0-0","driver":"qcow2","file":{"driver":"file","filename":"/export/target.qcow2"},"backing":"drive-ide0-0-0"} (QEMU) blockdev-backup device=drive-ide0-0-0 target=drive-ide1-0-0 sync=none { "execute": "blockdev-backup", "arguments": { "device": "drive-ide0-0-0", "target": "drive-ide1-0-0", "sync": "none" } } { "error": { "class": "GenericError", "desc": "Node 'drive-ide0-0-0' is busy: node is used as backing hd of '#block360'" } } With this patch applied ======================= `blockdev-backup` of an image to its immediate overlay succeds: ----------------------------------------------------------------------- (QEMU) blockdev-backup device=drive-ide0-0-0 target=drive-ide1-0-0 sync=none { "execute": "blockdev-backup", "arguments": { "device": "drive-ide0-0-0", "target": "drive-ide1-0-0", "sync": "none" } } { "return": {} } (QEMU) query-block-jobs { "execute": "query-block-jobs", "arguments": {} } { "return": [ { "busy": false, "type": "backup", "len": 41126400, "paused": false, "ready": false, "io-status": "ok", "offset": 0, "device": "drive-ide0-0-0", "speed": 0 } ] } -----------------------------------------------------------------------
diff --git a/block.c b/block.c index 9f037db..63e4636 100644 --- a/block.c +++ b/block.c @@ -1310,6 +1310,23 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) /* Otherwise we won't be able to commit due to check in bdrv_commit */ bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_COMMIT_TARGET, bs->backing_blocker); + /* + * We do backup in 3 ways: + * 1. drive backup + * The target bs is new opened, and the source is top BDS + * 2. blockdev backup + * Both the source and the target are top BDSes. + * 3. internal backup(used for block replication) + * Both the source and the target are backing file + * + * In case 1 and 2, neither the source nor the target is the backing file. + * In case 3, we will block the top BDS, so there is only one block job + * for the top BDS and its backing chain. + */ + bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_SOURCE, + bs->backing_blocker); + bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_TARGET, + bs->backing_blocker); out: bdrv_refresh_limits(bs, NULL); }