From: Amit Shah <amit.shah@redhat.com>
To: qemu list <qemu-devel@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
Markus Armbruster <armbru@redhat.com>,
Jes Sorensen <Jes.Sorensen@redhat.com>,
Amit Shah <amit.shah@redhat.com>
Subject: [Qemu-devel] [PATCH] atapi: Indicate 'medium not ready' to 'medium ready' transition via error
Date: Fri, 15 Apr 2011 15:03:49 +0530 [thread overview]
Message-ID: <cf1b3572fb325c9a918f3b62686e2f770cbe88d9.1302860026.git.amit.shah@redhat.com> (raw)
MMC-5 Table F.1 lists errors that can be thrown for the TEST_UNIT_READY
command. Going from medium not ready to medium ready states is
communicated by throwing an error.
This adds the missing 'tray opened' event that we fail to report to
guests. After doing this, older Linux guests properly revalidate a disc
on the change command. HSM violation errors, which caused Linux guests
to do a soft-reset of the link, also go away:
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6
sr 1:0:0:0: CDB: Test Unit Ready: 00 00 00 00 00 00
ata2.00: cmd a0/00:00:00:00:00/00:00:00:00:00/a0 tag 0
res 01/60:00:00:00:00/00:00:00:00:00/a0 Emask 0x3 (HSM violation)
ata2.00: status: { ERR }
ata2: soft resetting link
ata2.00: configured for MWDMA2
ata2: EH complete
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
hw/ide/core.c | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index f028ddb..5a72420 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -1253,9 +1253,16 @@ static void ide_atapi_cmd(IDEState *s)
if (bdrv_is_inserted(s->bs) && !s->cdrom_changed) {
ide_atapi_cmd_ok(s);
} else {
- s->cdrom_changed = 0;
- ide_atapi_cmd_error(s, SENSE_NOT_READY,
- ASC_MEDIUM_NOT_PRESENT);
+ int sense, asc;
+
+ sense = SENSE_NOT_READY;
+ asc = ASC_MEDIUM_NOT_PRESENT;
+ if (bdrv_is_inserted(s->bs) && s->cdrom_changed) {
+ s->cdrom_changed = 0;
+ sense = SENSE_UNIT_ATTENTION;
+ asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
+ }
+ ide_atapi_cmd_error(s, sense, asc);
}
break;
case GPCMD_MODE_SENSE_6:
@@ -1734,11 +1741,24 @@ static void cdrom_change_cb(void *opaque, int reason)
bdrv_get_geometry(s->bs, &nb_sectors);
s->nb_sectors = nb_sectors;
- s->sense_key = SENSE_UNIT_ATTENTION;
- s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
+ /*
+ * This function combines three actions a physical cdrom would do to
+ * change a disc in a drive:
+ *
+ * 1. eject the tray,
+ * 2. change the disc,
+ * 3. close the tray.
+ *
+ * Guests expect responses from us in the same order. So first,
+ * just mark the disc changed, but provide an 'ejected' event to
+ * the guest. Later, when the guest invokes a TEST_UNIT_READY
+ * command, we will provide with a disc change (UNIT_ATTENTION)
+ * event.
+ */
s->cdrom_changed = 1;
s->events.new_media = true;
- ide_set_irq(s->bus);
+
+ ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
}
static void ide_cmd_lba48_transform(IDEState *s, int lba48)
--
1.7.4.2
next reply other threads:[~2011-04-15 9:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-15 9:33 Amit Shah [this message]
2011-04-15 10:58 ` [Qemu-devel] [PATCH] atapi: Indicate 'medium not ready' to 'medium ready' transition via error Markus Armbruster
2011-04-15 11:05 ` Kevin Wolf
2011-04-15 11:11 ` Amit Shah
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cf1b3572fb325c9a918f3b62686e2f770cbe88d9.1302860026.git.amit.shah@redhat.com \
--to=amit.shah@redhat.com \
--cc=Jes.Sorensen@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).