From: Amit Shah <amit.shah@redhat.com>
To: qemu list <qemu-devel@nongnu.org>
Cc: Gleb Natapov <gleb@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
Markus Armbruster <armbru@redhat.com>,
Amit Shah <amit.shah@redhat.com>
Subject: [Qemu-devel] [RFC PATCH 3/3] atapi: Allow GET_EVENT_STATUS_NOTIFICATION and TEST_UNIT_READY after media change
Date: Fri, 1 Apr 2011 01:14:08 +0530 [thread overview]
Message-ID: <f59d12531f4f30e375caf01b0161bb61ffdace23.1301600598.git.amit.shah@redhat.com> (raw)
In-Reply-To: <2a24c3a3e75c383de13b87d064fb958ea9f268ff.1301600598.git.amit.shah@redhat.com>
In-Reply-To: <2a24c3a3e75c383de13b87d064fb958ea9f268ff.1301600598.git.amit.shah@redhat.com>
After a media change, the only commands allowed from the guest were
REQUEST_SENSE and INQUIRY. The guest may also issue
GET_EVENT_STATUS_NOTIFICATION and TEST_UNIT_READY commands to get media
changed notification. Enable those commands.
After this, the HSM violation messages from Linux guests aren't seen.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
hw/ide/core.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 89e212b..362a258 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -625,6 +625,14 @@ void ide_atapi_cmd_ok(IDEState *s)
ide_set_irq(s->bus);
}
+static void ide_atapi_cmd_ua(IDEState *s)
+{
+ s->sense_key = SENSE_UNIT_ATTENTION;
+ s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
+ ide_atapi_cmd_ok(s);
+ s->sense_key = SENSE_NONE;
+}
+
void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc)
{
#ifdef DEBUG_IDE_ATAPI
@@ -1243,20 +1251,26 @@ static void ide_atapi_cmd(IDEState *s)
/* If there's a UNIT_ATTENTION condition pending, only
REQUEST_SENSE and INQUIRY commands are allowed to complete. */
if (s->sense_key == SENSE_UNIT_ATTENTION &&
- s->io_buffer[0] != GPCMD_REQUEST_SENSE &&
- s->io_buffer[0] != GPCMD_INQUIRY) {
- ide_atapi_cmd_check_status(s);
- return;
+ s->io_buffer[0] != GPCMD_REQUEST_SENSE &&
+ s->io_buffer[0] != GPCMD_INQUIRY &&
+ s->io_buffer[0] != GPCMD_GET_EVENT_STATUS_NOTIFICATION &&
+ s->io_buffer[0] != GPCMD_TEST_UNIT_READY) {
+ ide_atapi_cmd_check_status(s);
+ return;
}
switch(s->io_buffer[0]) {
case GPCMD_TEST_UNIT_READY:
- if (bdrv_is_inserted(s->bs) && !s->cdrom_changed) {
- ide_atapi_cmd_ok(s);
+ if (bdrv_is_inserted(s->bs)) {
+ if (!s->cdrom_changed) {
+ ide_atapi_cmd_ok(s);
+ } else {
+ ide_atapi_cmd_ua(s);
+ }
} else {
- s->cdrom_changed = 0;
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIUM_NOT_PRESENT);
}
+ s->cdrom_changed = 0;
break;
case GPCMD_MODE_SENSE_6:
case GPCMD_MODE_SENSE_10:
--
1.7.4
next prev parent reply other threads:[~2011-03-31 19:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 16:40 [Qemu-devel] CD-ROM bug round-up Stefan Hajnoczi
2011-03-30 16:50 ` Gleb Natapov
2011-03-30 18:07 ` Stefan Hajnoczi
2011-03-31 9:53 ` [Qemu-devel] " Amit Shah
2011-03-31 14:03 ` Stefan Hajnoczi
2011-03-31 19:44 ` [Qemu-devel] [RFC PATCH 1/3] ide: Move GET_EVENT_STATUS_NOTIFICATION command handling to its own function Amit Shah
2011-03-31 19:44 ` [Qemu-devel] [RFC PATCH 2/3] atapi: implement GET_EVENT_STATUS_NOTIFICATION command Amit Shah
2011-03-31 19:44 ` Amit Shah [this message]
2011-03-31 9:56 ` [Qemu-devel] CD-ROM bug round-up Markus Armbruster
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=f59d12531f4f30e375caf01b0161bb61ffdace23.1301600598.git.amit.shah@redhat.com \
--to=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=gleb@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).