From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpdXz-0006Ka-3k for qemu-devel@nongnu.org; Fri, 23 Oct 2015 10:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpdXy-0008CW-0W for qemu-devel@nongnu.org; Fri, 23 Oct 2015 10:42:23 -0400 References: <1445270025-22999-1-git-send-email-mreitz@redhat.com> <1445270025-22999-33-git-send-email-mreitz@redhat.com> <20151023135435.GH3797@noname.redhat.com> From: Max Reitz Message-ID: <562A4746.5090008@redhat.com> Date: Fri, 23 Oct 2015 16:42:14 +0200 MIME-Version: 1.0 In-Reply-To: <20151023135435.GH3797@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TjvFs46WC0xXxUQfdxI5ugamR6qqALWm2" Subject: Re: [Qemu-devel] [PATCH v7 32/39] blockdev: Implement eject with basic operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --TjvFs46WC0xXxUQfdxI5ugamR6qqALWm2 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 23.10.2015 15:54, Kevin Wolf wrote: > Am 19.10.2015 um 17:53 hat Max Reitz geschrieben: >> Implement 'eject' by calling blockdev-open-tray and >> blockdev-remove-medium. >> >> Signed-off-by: Max Reitz >> --- >> blockdev.c | 11 +++++------ >> 1 file changed, 5 insertions(+), 6 deletions(-) >> >> diff --git a/blockdev.c b/blockdev.c >> index a4c278f..0481686 100644 >> --- a/blockdev.c >> +++ b/blockdev.c >> @@ -1941,16 +1941,15 @@ out: >> =20 >> void qmp_eject(const char *device, bool has_force, bool force, Error = **errp) >> { >> - BlockBackend *blk; >> + Error *local_err =3D NULL; >> =20 >> - blk =3D blk_by_name(device); >> - if (!blk) { >> - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, >> - "Device '%s' not found", device); >> + qmp_blockdev_open_tray(device, has_force, force, &local_err); >> + if (local_err) { >> + error_propagate(errp, local_err); >> return; >> } >=20 > This changes the behaviour, in the current patch series in two ways if > the device is locked: >=20 > 1. With force, the qmp_blockdev_remove_medium() call will fail because > we only unlocked the device, but didn't actually open the tray (I > commented on this in the qmp_blockdev_open_tray() patch). This break= s > the API, obviously. Yep, will fix. > 2. Without force, eject previously sent an eject request and also > returned a "Device is locked" error. Now it fails with "Tray of > device is not open". Regression in the message quality, but not an > API breakage because tools must not parse the message. I think this should be fine. The previous message wasn't too good in my opinion either, because the most likely scenario is this: User issues eject, management tool reports qemu's message: "Device is locked!" and then the tray opens. So that's strange, too. Maybe "Tray of device is not open" is actually the better message here, I don't know. It better describes the state, but it does not describe the reason... But in addition to that, there is no easy way around this. I could put a check into qmp_eject() which returns a "Device is locked" message if the tray is still closed after a successful qmp_blockdev_open_tray(), but I don't know whether that's worth it. Max >> - eject_device(blk, force, errp); >> + qmp_blockdev_remove_medium(device, errp); >> } >=20 > Kevin >=20 --TjvFs46WC0xXxUQfdxI5ugamR6qqALWm2 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 iQEcBAEBCAAGBQJWKkdGAAoJEDuxQgLoOKytIg8H/it5LMSunhZHkyZcGtts0aF7 Ps5CcoYiyeiFKVSov4DNzM8d4PQYc3kBJ7yGtP7z+7++Cu2kEDCt9N5Q4c6aR03B OOye3k99spao+vKNKP8Bi6ZV79ydGam8p4hNuLIcpz+6eSb30q4vgpPOFyiVXGjA f5Fkf4S+PxmT6x8KswimeJAWdkFkeYnbWsatyOgYu7vmpM9Eo4ARv/6IVUJYhdLr LlLcvPaeKDdwdW6h31qrtWpjliHVXGg9vcBRRzD2330GLRzVselepNy4oCN32qAt TTWx0KhQbA0oICMCdI86iFWvCP6IsRiDuC82Y6Qugdd7jYnxutW7RbWjkFmzCz4= =BZ7k -----END PGP SIGNATURE----- --TjvFs46WC0xXxUQfdxI5ugamR6qqALWm2--