From patchwork Mon Sep 12 14:19:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 114348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AB307B70D6 for ; Tue, 13 Sep 2011 00:18:49 +1000 (EST) Received: from localhost ([::1]:42665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R37LS-0004V7-SJ for incoming@patchwork.ozlabs.org; Mon, 12 Sep 2011 10:18:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]:38646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R37K6-0001xu-NR for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R37K5-0007BD-7D for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R37K4-0007Az-TY for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:21 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8CEHJMO020707 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 12 Sep 2011 10:17:19 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8CEGa32030698; Mon, 12 Sep 2011 10:17:18 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Mon, 12 Sep 2011 16:19:30 +0200 Message-Id: <1315837174-15327-32-git-send-email-kwolf@redhat.com> In-Reply-To: <1315837174-15327-1-git-send-email-kwolf@redhat.com> References: <1315837174-15327-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 31/35] ide/atapi scsi-disk: Make monitor eject -f, then change work X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster 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 Signed-off-by: Kevin Wolf --- 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 5def25c..9297b9e 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)