Received: from eggs.gnu.org ([2001:4830:134:3::10]:34330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0bWp-0005D4-Cs for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:09:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0bWk-0006vO-9N for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:09:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0bWk-0006vG-1E for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:09:38 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5RJ9bes000703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 27 Jun 2014 15:09:37 -0400 From: Kevin Wolf Date: Fri, 27 Jun 2014 21:08:39 +0200 Message-Id: <1403896146-3063-21-git-send-email-kwolf@redhat.com> In-Reply-To: <1403896146-3063-1-git-send-email-kwolf@redhat.com> References: <1403896146-3063-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 20/47] block: Add node-name argument to drive-mirror List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Beno=C3=AEt Canet This new argument can be used to specify the node-name of the new mirrore= d BDS. Signed-off-by: Benoit Canet Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- blockdev.c | 11 +++++++++-- hmp.c | 1 + qapi/block-core.json | 4 ++++ qmp-commands.hx | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index e8bfa3c..9433012 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2099,6 +2099,7 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Er= ror **errp) =20 void qmp_drive_mirror(const char *device, const char *target, bool has_format, const char *format, + bool has_node_name, const char *node_name, enum MirrorSyncMode sync, bool has_mode, enum NewImageMode mode, bool has_speed, int64_t speed, @@ -2112,6 +2113,7 @@ void qmp_drive_mirror(const char *device, const cha= r *target, BlockDriverState *source, *target_bs; BlockDriver *drv =3D NULL; Error *local_err =3D NULL; + QDict *options =3D NULL; int flags; int64_t size; int ret; @@ -2213,12 +2215,17 @@ void qmp_drive_mirror(const char *device, const c= har *target, return; } =20 + if (has_node_name) { + options =3D qdict_new(); + qdict_put(options, "node-name", qstring_from_str(node_name)); + } + /* Mirroring takes care of copy-on-write using the source's backing * file. */ target_bs =3D NULL; - ret =3D bdrv_open(&target_bs, target, NULL, NULL, flags | BDRV_O_NO_= BACKING, - drv, &local_err); + ret =3D bdrv_open(&target_bs, target, NULL, options, + flags | BDRV_O_NO_BACKING, drv, &local_err); if (ret < 0) { error_propagate(errp, local_err); return; diff --git a/hmp.c b/hmp.c index dc3d279..73acc32 100644 --- a/hmp.c +++ b/hmp.c @@ -933,6 +933,7 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdic= t) } =20 qmp_drive_mirror(device, filename, !!format, format, + false, NULL, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP= , true, mode, false, 0, false, 0, false, 0, false, 0, false, 0, &err); diff --git a/qapi/block-core.json b/qapi/block-core.json index de31f9f..a46cdbe 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -765,6 +765,9 @@ # @format: #optional the format of the new destination, default is to # probe if @mode is 'existing', else the format of the source # +# @node-name: #optional the new block driver state node name in the grap= h +# (Since 2.1) +# # @mode: #optional whether and how QEMU should create a new image, defau= lt is # 'absolute-paths'. # @@ -797,6 +800,7 @@ ## { 'command': 'drive-mirror', 'data': { 'device': 'str', 'target': 'str', '*format': 'str', + '*node-name': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', '*speed': 'int', '*granularity': 'uint32', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', diff --git a/qmp-commands.hx b/qmp-commands.hx index e4a1c80..5254938 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1293,6 +1293,7 @@ EQMP { .name =3D "drive-mirror", .args_type =3D "sync:s,device:B,target:s,speed:i?,mode:s?,forma= t:s?," + "node-name:s?," "on-source-error:s?,on-target-error:s?," "granularity:i?,buf-size:i?", .mhandler.cmd_new =3D qmp_marshal_input_drive_mirror, @@ -1314,6 +1315,8 @@ Arguments: - "device": device name to operate on (json-string) - "target": name of new image file (json-string) - "format": format of new image (json-string, optional) +- "node-name": the name of the new block driver state in the node graph + (json-string, optional) - "mode": how an image file should be created into the target file/device (NewImageMode, optional, default 'absolute-paths') - "speed": maximum speed of the streaming job, in bytes per second --=20 1.8.3.1