From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zpcns-0006Bm-UO for qemu-devel@nongnu.org; Fri, 23 Oct 2015 09:54:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zpcns-0007i4-58 for qemu-devel@nongnu.org; Fri, 23 Oct 2015 09:54:44 -0400 Date: Fri, 23 Oct 2015 15:54:35 +0200 From: Kevin Wolf Message-ID: <20151023135435.GH3797@noname.redhat.com> References: <1445270025-22999-1-git-send-email-mreitz@redhat.com> <1445270025-22999-33-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1445270025-22999-33-git-send-email-mreitz@redhat.com> 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: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi 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: > > void qmp_eject(const char *device, bool has_force, bool force, Error **errp) > { > - BlockBackend *blk; > + Error *local_err = NULL; > > - blk = 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; > } This changes the behaviour, in the current patch series in two ways if the device is locked: 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 breaks the API, obviously. 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. > - eject_device(blk, force, errp); > + qmp_blockdev_remove_medium(device, errp); > } Kevin