From: Pavel Hrdina <phrdina@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, phrdina@redhat.com
Subject: [Qemu-devel] [PATCH v4 1/1] atapi: make change media detection for guests easier
Date: Mon, 26 Nov 2012 16:37:39 +0100 [thread overview]
Message-ID: <28e9cb8033528aceee73614d8231c0786704df88.1353943996.git.phrdina@redhat.com> (raw)
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".
v4: - removed fake_cdrom_changed introduced in v3
- cleaned ide_drive_post_load
v3: - remove timeout as it isn't needed anymore
v2: - disable debug messages
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
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 7d6b0fa..d8f76e5 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2147,12 +2147,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)));
}
--
1.7.11.7
next reply other threads:[~2012-11-26 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 15:37 Pavel Hrdina [this message]
2012-11-26 15:54 ` [Qemu-devel] [PATCH v4 1/1] atapi: make change media detection for guests easier Kevin Wolf
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=28e9cb8033528aceee73614d8231c0786704df88.1353943996.git.phrdina@redhat.com \
--to=phrdina@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).