Received: from eggs.gnu.org ([2001:4830:134:3::10]:34076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmT53-0003hm-JP for qemu-devel@nongnu.org; Tue, 20 Sep 2016 17:59:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmT51-0001ss-UM for qemu-devel@nongnu.org; Tue, 20 Sep 2016 17:59:57 -0400 References: <1474376602-9665-1-git-send-email-kwolf@redhat.com> <1474376602-9665-12-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <09b18eb6-0df3-704a-6ade-bda9efb62b34@redhat.com> Date: Tue, 20 Sep 2016 16:59:47 -0500 MIME-Version: 1.0 In-Reply-To: <1474376602-9665-12-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Lb8bGhJoEKvpkS3J3dPVAfJD721E7HobD" Subject: Re: [Qemu-devel] [PATCH v2 11/11] block: Remove BB interface from blockdev-add/del List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Lb8bGhJoEKvpkS3J3dPVAfJD721E7HobD From: Eric Blake To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, qemu-devel@nongnu.org Message-ID: <09b18eb6-0df3-704a-6ade-bda9efb62b34@redhat.com> Subject: Re: [PATCH v2 11/11] block: Remove BB interface from blockdev-add/del References: <1474376602-9665-1-git-send-email-kwolf@redhat.com> <1474376602-9665-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1474376602-9665-12-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/20/2016 08:03 AM, Kevin Wolf wrote: > With this patch, blockdev-add always works on a node level, i.e. it > creates a BDS, but no BB. Consequently, x-blockdev-del doesn't need the= > 'device' option any more, but 'node-name' becomes mandatory. How close are we to promoting x-blockdev-del out of the x- namespace? Do we "just" need the remaining blockdev devices exposed in QMP? >=20 > Signed-off-by: Kevin Wolf > --- > blockdev.c | 127 ++++++++++++++----------------------------= -------- > docs/qmp-commands.txt | 24 +++------- > qapi/block-core.json | 30 +++--------- > 3 files changed, 49 insertions(+), 132 deletions(-) >=20 > void qmp_blockdev_add(BlockdevOptions *options, Error **errp) > { > BlockDriverState *bs; > - BlockBackend *blk =3D NULL; > QObject *obj; > Visitor *v =3D qmp_output_visitor_new(&obj); > QDict *qdict; > @@ -3861,37 +3860,22 @@ void qmp_blockdev_add(BlockdevOptions *options,= Error **errp) > =20 > qdict_flatten(qdict); > =20 > - if (options->has_id) { > - blk =3D blockdev_init(NULL, qdict, &local_err); > - if (local_err) { > - error_propagate(errp, local_err); > - goto fail; > - } > - > - bs =3D blk_bs(blk); > - } else { > - if (!qdict_get_try_str(qdict, "node-name")) { > - error_setg(errp, "'id' and/or 'node-name' need to be speci= fied for " > - "the root node"); > - goto fail; > - } > - > - bs =3D bds_tree_init(qdict, errp); > - if (!bs) { > - goto fail; > - } > + if (!qdict_get_try_str(qdict, "node-name")) { > + error_setg(errp, "'id' and/or 'node-name' need to be specified= for " > + "the root node"); Umm, 'id' can't be specified, after this change :) > -void qmp_x_blockdev_del(bool has_id, const char *id, > - bool has_node_name, const char *node_name, Err= or **errp) > +void qmp_x_blockdev_del(const char *node_name, Error **errp) > { > AioContext *aio_context; > - BlockBackend *blk; > BlockDriverState *bs; > =20 > - if (has_id && has_node_name) { > - error_setg(errp, "Only one of id and node-name must be specifi= ed"); > - return; > - } else if (!has_id && !has_node_name) { > - error_setg(errp, "No block device specified"); > + bs =3D bdrv_find_node(node_name); > + if (!bs) { > + error_setg(errp, "Cannot find node %s", node_name); > return; > } > - > - if (has_id) { > - /* blk_by_name() never returns a BB that is not owned by the m= onitor */ > - blk =3D blk_by_name(id); > - if (!blk) { > - error_setg(errp, "Cannot find block backend %s", id); > - return; > - } > - if (blk_legacy_dinfo(blk)) { > - error_setg(errp, "Deleting block backend added with drive-= add" > - " is not supported"); > - return; > - } > - if (blk_get_refcnt(blk) > 1) { > - error_setg(errp, "Block backend %s is in use", id); > - return; > - } > - bs =3D blk_bs(blk); > - aio_context =3D blk_get_aio_context(blk); > - } else { > - blk =3D NULL; > - bs =3D bdrv_find_node(node_name); > - if (!bs) { > - error_setg(errp, "Cannot find node %s", node_name); > - return; > - } > - if (bdrv_has_blk(bs)) { > - error_setg(errp, "Node %s is in use by %s", > - node_name, bdrv_get_parent_name(bs)); > - return; > - } > - aio_context =3D bdrv_get_aio_context(bs); > + if (bdrv_has_blk(bs)) { > + error_setg(errp, "Node %s is in use by %s", > + node_name, bdrv_get_parent_name(bs)); Is this the source of the "(null)" I was asking about in 10/11? > +++ b/docs/qmp-commands.txt > @@ -3141,7 +3141,7 @@ Example (2): > "arguments": { > "options": { > "driver": "qcow2", > - "id": "my_disk", > + "node-name": "my_disk", > "discard": "unmap", > "cache": { > "direct": true, > @@ -3168,18 +3168,9 @@ x-blockdev-del > ------------ > Since 2.5 > =20 > -Deletes a block device thas has been added using blockdev-add. > -The selected device can be either a block backend or a graph node. > - > -In the former case the backend will be destroyed, along with its > -inserted medium if there's any. The command will fail if the backend > -or its medium are in use. > - > -In the latter case the node will be destroyed. The command will fail > -if the node is attached to a block backend or is otherwise being > -used. > - > -One of "id" or "node-name" must be specified, but not both. > +Deletes a block device that has been added using blockdev-add. > +The command will fail # if the node is attached to a device or is Spurious #. > +++ b/qapi/block-core.json > @@ -2217,13 +2217,8 @@ > # block devices, independent of the block driver: > # > # @driver: block driver name > -# @id: #optional id by which the new block device can be re= ferred to. > -# This option is only allowed on the top level of bloc= kdev-add. > -# A BlockBackend will be created by blockdev-add if an= d only if > -# this option is given. Removing an option. Not backward-compatible, but we've been warning users that blockdev-add is not ready for primetime yet, so I'm okay with it (and at least introspection shows it). > -# @node-name: #optional the name of a block driver state node (Sin= ce 2.0). > -# This option is required on the top level of blockdev= -add if > -# the @id option is not given there. > +# @node-name: #optional the node name of the new node (Since 2.0).= > +# This option is required on the top level of blockdev= -add. > # @discard: #optional discard-related options (default: ignore) > # @cache: #optional cache-related options > # @aio: #optional AIO backend (default: threads) > @@ -2238,8 +2233,6 @@ > ## > { 'union': 'BlockdevOptions', > 'base': { 'driver': 'BlockdevDriver', > -# TODO 'id' is a BB-level option, remove it > - '*id': 'str', > '*node-name': 'str', > '*discard': 'BlockdevDiscardOptions', > '*cache': 'BlockdevCacheOptions', > @@ -2323,29 +2316,18 @@ > # @x-blockdev-del: > # > # Deletes a block device that has been added using blockdev-add. > -# The selected device can be either a block backend or a graph node. > -# > -# In the former case the backend will be destroyed, along with its > -# inserted medium if there's any. The command will fail if the backend= > -# or its medium are in use. > -# > -# In the latter case the node will be destroyed. The command will fail= > -# if the node is attached to a block backend or is otherwise being > -# used. > -# > -# One of @id or @node-name must be specified, but not both. > +# The command will fail # if the node is attached to a device or is > +# otherwise being used. Spurious # (copy-and-paste strikes again) Overall, I like the result, but I think it needs just a bit of polish before I give R-b. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Lb8bGhJoEKvpkS3J3dPVAfJD721E7HobD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX4bFTAAoJEKeha0olJ0Nqgk4H+wc/OQf2WoYk5K+V9Bm9wIha EEV2WGI21iaBhxXWs70a2Ve6zC9CM6mecEw2nGpURVzulEYdPo6iTld4+Qwo5drD +XdOacesWI9RJU0g+LkrzTcrwWb/a6nArqCIu5HjhkNzidHZo4d8e2bpeHHvHVS0 Il6qfpDpxIVp6EdcxxUUAEeZn1im7OH+/vRV9pyvQYp4XFNzDI/GVzB++2QrIYLW LRami+N8RhRmHZtVJgke3+OdFPsSOLHIS9gkjfbzcv+ZrQvCGIKtPzd4LKF+KB+U i1gC7EHgHi0KnmctiV3IlzEos/TzMsdOt2fyUWnM3paos0o0PSeiuEiOUZmQXSY= =y3sy -----END PGP SIGNATURE----- --Lb8bGhJoEKvpkS3J3dPVAfJD721E7HobD--