From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1CG1-0004H5-JJ for qemu-devel@nongnu.org; Wed, 07 Sep 2011 03:09:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1CG0-0003v7-M1 for qemu-devel@nongnu.org; Wed, 07 Sep 2011 03:09:13 -0400 Received: from mail-vw0-f53.google.com ([209.85.212.53]:43919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1CG0-0003v2-Gi for qemu-devel@nongnu.org; Wed, 07 Sep 2011 03:09:12 -0400 Received: by vws13 with SMTP id 13so6048446vws.12 for ; Wed, 07 Sep 2011 00:09:12 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4E671893.8050609@redhat.com> Date: Wed, 07 Sep 2011 09:09:07 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1315328340-6192-1-git-send-email-armbru@redhat.com> <1315328340-6192-28-git-send-email-armbru@redhat.com> In-Reply-To: <1315328340-6192-28-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 27/27] ide/atapi scsi-disk: Make monitor eject -f, then change work List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, stefano.stabellini@eu.citrix.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, hare@suse.de, amit.shah@redhat.com, hch@lst.de On 09/06/2011 06:59 PM, Markus Armbruster wrote: > change fails while the tray is locked by the guest. eject -f forces > it open and removes any media. Unfortunately, the tray closes again > instantly. Since the lock remains as it is, there is no way to insert > another medium unless the guest voluntarily unlocks. > > Fix by leaving the tray open after monitor eject. > > Signed-off-by: Markus Armbruster > --- > blockdev.c | 3 ++- > hw/ide/core.c | 1 + > hw/scsi-disk.c | 1 + > 3 files changed, 4 insertions(+), 1 deletions(-) > > diff --git a/blockdev.c b/blockdev.c > index 154cc84..0827bf7 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -635,7 +635,8 @@ static int eject_device(Monitor *mon, BlockDriverState *bs, int force) > qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs)); > return -1; > } > - if (!force&& bdrv_dev_is_medium_locked(bs)) { > + if (!force&& !bdrv_dev_is_tray_open(bs) > +&& bdrv_dev_is_medium_locked(bs)) { > qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); > return -1; > } > diff --git a/hw/ide/core.c b/hw/ide/core.c > index bc83c46..db144aa 100644 > --- a/hw/ide/core.c > +++ b/hw/ide/core.c > @@ -789,6 +789,7 @@ static void ide_cd_change_cb(void *opaque, bool load) > IDEState *s = opaque; > uint64_t nb_sectors; > > + s->tray_open = !load; > bdrv_get_geometry(s->bs,&nb_sectors); > s->nb_sectors = nb_sectors; > > diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c > index f5f1d82..4a60820 100644 > --- a/hw/scsi-disk.c > +++ b/hw/scsi-disk.c > @@ -1175,6 +1175,7 @@ static void scsi_destroy(SCSIDevice *dev) > > static void scsi_cd_change_media_cb(void *opaque, bool load) > { > + ((SCSIDiskState *)opaque)->tray_open = !load; > } > > static bool scsi_cd_is_tray_open(void *opaque) Reviewed-by: Paolo Bonzini