From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxFZv-0008Fg-UU for qemu-devel@nongnu.org; Wed, 18 Jun 2014 09:07:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxFZp-0008EK-Ur for qemu-devel@nongnu.org; Wed, 18 Jun 2014 09:07:03 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:51531 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxFZp-0008Dp-Me for qemu-devel@nongnu.org; Wed, 18 Jun 2014 09:06:57 -0400 Date: Wed, 18 Jun 2014 15:06:56 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140618130656.GC4107@irqsave.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 for 2.1 07/10] block: add ability for block-stream to use node-name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, benoit.canet@irqsave.net, pkrempa@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com The Tuesday 17 Jun 2014 =E0 17:53:55 (-0400), Jeff Cody wrote : > This adds the ability for block-stream to use node-name arguments > for base, to specify the backing image to stream from. >=20 > Both 'base' and 'base-node-name' are optional, but mutually exclusive. > Either can be specified, but not both together. >=20 > Reviewed-by: Eric Blake > Signed-off-by: Jeff Cody > --- > blockdev.c | 48 +++++++++++++++++++++++++++++++++++++++-----= ---- > hmp.c | 2 +- > qapi/block-core.json | 16 ++++++++++++---- > qmp-commands.hx | 2 +- > 4 files changed, 53 insertions(+), 15 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index 7a1c966..2926738 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1868,38 +1868,68 @@ static void block_job_cb(void *opaque, int ret) > bdrv_put_ref_bh_schedule(bs); > } > =20 > -void qmp_block_stream(const char *device, bool has_base, > - const char *base, bool has_speed, int64_t speed, > +void qmp_block_stream(const char *device, > + bool has_base, const char *base, > + bool has_base_node_name, const char *base_node_n= ame, > + bool has_speed, int64_t speed, > bool has_on_error, BlockdevOnError on_error, > Error **errp) > { > - BlockDriverState *bs; > + BlockDriverState *bs =3D NULL; > BlockDriverState *base_bs =3D NULL; > + BlockDriverState *tmp_bs; > Error *local_err =3D NULL; > + const char *base_name =3D NULL; > =20 > if (!has_on_error) { > on_error =3D BLOCKDEV_ON_ERROR_REPORT; > } > =20 > + if (has_base && has_base_node_name) { > + error_setg(errp, "'base' and 'base-node-name' are mutually exc= lusive"); > + return; > + } > + > bs =3D bdrv_find(device); > if (!bs) { > error_set(errp, QERR_DEVICE_NOT_FOUND, device); > return; > } > =20 > + if (has_base_node_name) { > + base_bs =3D bdrv_lookup_bs(NULL, base_node_name, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + return; > + } > + tmp_bs =3D bdrv_find_overlay(bs, base_bs); > + if (tmp_bs) { > + base_name =3D tmp_bs->backing_file; > + } > + } > + > if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) { > return; > } > =20 > - if (base) { > + if (has_base) { > base_bs =3D bdrv_find_backing_image(bs, base); > - if (base_bs =3D=3D NULL) { > - error_set(errp, QERR_BASE_NOT_FOUND, base); > - return; > - } > + base_name =3D base; > + } > + > + if (base_bs =3D=3D NULL && (has_base || has_base_node_name)) { > + error_set(errp, QERR_BASE_NOT_FOUND, base); > + return; > + } > + > + /* Verify that 'base' is in the same chain as 'bs', if 'base' was > + * specified */ > + if (base_bs && !bdrv_chain_contains(bs, base_bs)) { > + error_setg(errp, "'device' and 'base' are not in the same chai= n"); > + return; > } > =20 > - stream_start(bs, base_bs, base, has_speed ? speed : 0, > + stream_start(bs, base_bs, base_name, has_speed ? speed : 0, > on_error, block_job_cb, bs, &local_err); > if (local_err) { > error_propagate(errp, local_err); > diff --git a/hmp.c b/hmp.c > index ccc35d4..bb934df 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1173,7 +1173,7 @@ void hmp_block_stream(Monitor *mon, const QDict *= qdict) > int64_t speed =3D qdict_get_try_int(qdict, "speed", 0); > =20 > qmp_block_stream(device, base !=3D NULL, base, > - qdict_haskey(qdict, "speed"), speed, > + false, NULL, qdict_haskey(qdict, "speed"), speed, > true, BLOCKDEV_ON_ERROR_REPORT, &error); > =20 > hmp_handle_error(mon, &error); > diff --git a/qapi/block-core.json b/qapi/block-core.json > index ae1dde9..d17e349 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -904,9 +904,17 @@ > # On successful completion the image file is updated to drop the backi= ng file > # and the BLOCK_JOB_COMPLETED event is emitted. > # > -# @device: the device name > +# @device: The device name. > +# > +# For 'base', either @base or @base-node-name may be set but not both.= If > +# neither is specified, the entire chain will be streamed into the act= ive image, > +# and the chain will consist of a single image (the current active lay= er) with > +# no backing file. > # > -# @base: #optional the common backing file name > +# @base: #optional the common backing file name > +# > +# @base-node-name: #optional the block driver state node name of the > +# common backing file. (Since 2.1) > # > # @speed: #optional the maximum speed, in bytes per second > # > @@ -920,8 +928,8 @@ > # Since: 1.1 > ## > { 'command': 'block-stream', > - 'data': { 'device': 'str', '*base': 'str', '*speed': 'int', > - '*on-error': 'BlockdevOnError' } } > + 'data': { 'device': 'str', '*base': 'str', '*base-node-name': 'str', > + '*speed': 'int', '*on-error': 'BlockdevOnError' } } > =20 > ## > # @block-job-set-speed: > diff --git a/qmp-commands.hx b/qmp-commands.hx > index 7eb90a9..41e3853 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -979,7 +979,7 @@ EQMP > =20 > { > .name =3D "block-stream", > - .args_type =3D "device:B,base:s?,speed:o?,on-error:s?", > + .args_type =3D "device:B,base:s?,base-node-name:s?,speed:o?,o= n-error:s?", > .mhandler.cmd_new =3D qmp_marshal_input_block_stream, > }, > =20 > --=20 > 1.9.3 >=20 Reviewed-by: Benoit Canet