From patchwork Fri Nov 30 13:02:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 202942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 86B422C0095 for ; Sat, 1 Dec 2012 00:03:06 +1100 (EST) Received: from localhost ([::1]:36485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeQFE-0002x3-7l for incoming@patchwork.ozlabs.org; Fri, 30 Nov 2012 08:03:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeQEp-0002nE-Js for qemu-devel@nongnu.org; Fri, 30 Nov 2012 08:02:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TeQEo-0003he-Fq for qemu-devel@nongnu.org; Fri, 30 Nov 2012 08:02:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeQEn-0003fz-S2 for qemu-devel@nongnu.org; Fri, 30 Nov 2012 08:02:38 -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 qAUD2aVC018308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 30 Nov 2012 08:02:36 -0500 Received: from dhcp-5-188.str.redhat.com (vpn1-4-186.ams2.redhat.com [10.36.4.186]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAUD2U9X032316; Fri, 30 Nov 2012 08:02:35 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 30 Nov 2012 14:02:27 +0100 Message-Id: <1354280549-5954-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1354280549-5954-1-git-send-email-kwolf@redhat.com> References: <1354280549-5954-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/5] atapi: make change media detection for guests easier 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: Pavel Hrdina If you have a guest with a media in the optical drive and you change it, the windows guest cannot properly recognize this media change. Windows needs to detect sense "NOT_READY with ASC_MEDIUM_NOT_PRESENT" before we send sense "UNIT_ATTENTION with ASC_MEDIUM_MAY_HAVE_CHANGED". Signed-off-by: Pavel Hrdina Signed-off-by: Kevin Wolf --- hw/ide/atapi.c | 15 ++++++++++----- hw/ide/core.c | 6 ------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index 685cbaa..861fd2b 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -1124,12 +1124,17 @@ void ide_atapi_cmd(IDEState *s) * GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close * states rely on this behavior. */ - if (!s->tray_open && bdrv_is_inserted(s->bs) && s->cdrom_changed) { - ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT); + if (!(atapi_cmd_table[s->io_buffer[0]].flags & ALLOW_UA) && + !s->tray_open && bdrv_is_inserted(s->bs) && s->cdrom_changed) { + + if (s->cdrom_changed == 1) { + ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT); + s->cdrom_changed = 2; + } else { + ide_atapi_cmd_error(s, UNIT_ATTENTION, ASC_MEDIUM_MAY_HAVE_CHANGED); + s->cdrom_changed = 0; + } - s->cdrom_changed = 0; - s->sense_key = UNIT_ATTENTION; - s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED; return; } diff --git a/hw/ide/core.c b/hw/ide/core.c index 8da894f..c4f93d0 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2160,12 +2160,6 @@ static int ide_drive_post_load(void *opaque, int version_id) { IDEState *s = opaque; - if (version_id < 3) { - if (s->sense_key == UNIT_ATTENTION && - s->asc == ASC_MEDIUM_MAY_HAVE_CHANGED) { - s->cdrom_changed = 1; - } - } if (s->identify_set) { bdrv_set_enable_write_cache(s->bs, !!(s->identify_data[85] & (1 << 5))); }