From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGYxT-0002EE-BO for qemu-devel@nongnu.org; Wed, 28 Jan 2015 15:11:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGYxO-0005QE-EP for qemu-devel@nongnu.org; Wed, 28 Jan 2015 15:11:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGYxO-0005PX-5o for qemu-devel@nongnu.org; Wed, 28 Jan 2015 15:11:22 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0SKBKuX014035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 28 Jan 2015 15:11:21 -0500 Message-ID: <54C94267.5040506@redhat.com> Date: Wed, 28 Jan 2015 13:11:19 -0700 From: Eric Blake MIME-Version: 1.0 References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> <1422387983-32153-41-git-send-email-mreitz@redhat.com> In-Reply-To: <1422387983-32153-41-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="X6Xk3aMtrFS1hIUbRh1mDK3wMfQ127IDe" Subject: Re: [Qemu-devel] [PATCH RESEND 40/50] blockdev: Add blockdev-remove-medium List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Jeff Cody , Markus Armbruster , Stefan Hajnoczi , John Snow This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --X6Xk3aMtrFS1hIUbRh1mDK3wMfQ127IDe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/27/2015 12:46 PM, Max Reitz wrote: > Signed-off-by: Max Reitz > --- > blockdev.c | 25 +++++++++++++++++++++++++ > qapi/block-core.json | 13 +++++++++++++ > qmp-commands.hx | 43 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 81 insertions(+) >=20 > =20 > +void qmp_blockdev_remove_medium(const char *device, Error **errp) > +{ > + if (!blk_dev_is_tray_open(blk)) { > + error_setg(errp, "Tray of device '%s' is not open", device); > + return; > + } > + > + if (blk_bs(blk)) { > + blk_remove_bs(blk); Another intentional no-op if there is already no medium; worth documenting alongside the other touchups. > =20 > +## > +# @blockdev-remove-medium: > +# > +# Removes a medium (a block driver state tree) from a block device. Th= at block > +# device's tray must currently be open. > +# > +# @device: block device name > +# > +# Since: 2.3 > +## > +{ 'command': 'blockdev-remove-medium', > + 'data': { 'device': 'str' } } Just thinking aloud - obviously, this is a device operation. But do we want to allow specifying the device by the node-name of the BDS being removed? (I suppose the same applies to 38 [open a tray by the name of the BDS in the tray] and 39 [close a tray that has the given BDS inserted]). But I'm fine with naming the parameter 'device', even if we allow for a BDS->BB lookup when actually resolving the user's input, since that would only be a convenience (and not like other block API that specifically operate on nodes of a BDS tree rather than a device). Furthermore, the counterpart command for inserting a medium (later in this series) is one case where we CAN'T do the BDS->BB lookup (generally, insertion will fail if a BDS node is already in the BB device, unless you implement swap semantics, but that would make it confusing to insert one BDS into the device referenced by another BDS->BB lookup); and symmetry argues that if that command supports ONLY a BB name, then all of the related commands are just fine using 'device' as their parameter name to imply BB name. So I'm fine with the naming you've used so far. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --X6Xk3aMtrFS1hIUbRh1mDK3wMfQ127IDe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJUyUJnAAoJEKeha0olJ0Nq6nMH/1G/UAHhHbtoZO+eSszT733l ewLRv0iv9oNViJu8ahoYOlaypq9A7QLi/OjJFQXh1CIOFheuEqlA0DAWFTZxsfU6 sH2H9CikyQTRARH26DkIAqTaVOnQK+eVTwstrHGiwabE8YwzyH9utGY91jKZ4R9B NeKWwMp7HZfmeiMr7seXiGQWUwB9k4TlyZGp0+UQ6tuzzzxKGr/+N5TsP49CnEKT y18bM14soD4sXSld6efGgNJdKAlhq63xBfXfEsBOvvzxO97xQQDRAFOVZhJr+B0b iu2CJDh15ShJgNoUCiDsojegS/h7NokJrnfbdzlOQkaGGXfE5Mf53j5GWNiMHr4= =oa+M -----END PGP SIGNATURE----- --X6Xk3aMtrFS1hIUbRh1mDK3wMfQ127IDe--