From: Gleb Natapov <gleb@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2] make windows notice media change
Date: Wed, 29 Jul 2009 16:50:57 +0300 [thread overview]
Message-ID: <20090729135057.GY30449@redhat.com> (raw)
In-Reply-To: <20090729120719.GN30449@redhat.com>
Windows seems to be very stupid about cdrom media change. It polls
cdrom status and if status goes ready->media not present->ready
it assumes that media was changed. If "media not present" step doesn't
happen even if "medium may have changed" was seen it assumes media
haven't changed. Fake "media not present" step.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
v1->v2:
do not reuse media_changed. Save/restore on migration.
diff --git a/hw/ide.c b/hw/ide.c
index 1e56786..b8f35ad 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -418,6 +418,7 @@ typedef struct IDEState {
/* ATAPI specific */
uint8_t sense_key;
uint8_t asc;
+ uint8_t cdrom_changed;
int packet_transfer_size;
int elementary_transfer_size;
int io_buffer_index;
@@ -1644,9 +1645,10 @@ static void ide_atapi_cmd(IDEState *s)
}
switch(s->io_buffer[0]) {
case GPCMD_TEST_UNIT_READY:
- if (bdrv_is_inserted(s->bs)) {
+ 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);
}
@@ -2106,7 +2108,7 @@ static void cdrom_change_cb(void *opaque)
s->sense_key = SENSE_UNIT_ATTENTION;
s->asc = ASC_MEDIUM_MAY_HAVE_CHANGED;
-
+ s->cdrom_changed = 1;
ide_set_irq(s);
}
@@ -2870,6 +2872,7 @@ static void ide_save(QEMUFile* f, IDEState *s)
qemu_put_8s(f, &s->sense_key);
qemu_put_8s(f, &s->asc);
+ qemu_put_8s(f, &s->cdrom_changed);
/* XXX: if a transfer is pending, we do not save it yet */
}
@@ -2898,6 +2901,7 @@ static void ide_load(QEMUFile* f, IDEState *s)
qemu_get_8s(f, &s->sense_key);
qemu_get_8s(f, &s->asc);
+ qemu_get_8s(f, &s->cdrom_changed);
/* XXX: if a transfer is pending, we do not save it yet */
}
@@ -3219,7 +3223,7 @@ static int pci_ide_load(QEMUFile* f, void *opaque, int version_id)
PCIIDEState *d = opaque;
int ret, i;
- if (version_id != 2)
+ if (version_id != 3)
return -EINVAL;
ret = pci_device_load(&d->dev, f);
if (ret < 0)
@@ -3339,7 +3343,7 @@ void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], irq[0]);
ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], irq[1]);
- register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d);
+ register_savevm("ide", 0, 3, pci_ide_save, pci_ide_load, d);
qemu_register_reset(cmd646_reset, d);
cmd646_reset(d);
}
--
Gleb.
next prev parent reply other threads:[~2009-07-29 13:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 12:07 [Qemu-devel] [PATCH] make windows notice media change Gleb Natapov
2009-07-29 13:50 ` Gleb Natapov [this message]
2009-07-29 14:22 ` [Qemu-devel] [PATCH v2] " Avi Kivity
2009-07-29 14:21 ` Gleb Natapov
2009-07-29 14:44 ` Avi Kivity
2009-07-29 14:35 ` Filip Navara
2009-07-29 14:40 ` Gleb Natapov
2009-07-29 14:59 ` Stefano Stabellini
2009-07-29 19:11 ` Paul Brook
2009-07-29 19:18 ` Filip Navara
2009-07-29 19:24 ` Filip Navara
2009-07-29 19:34 ` Anthony Liguori
2009-07-29 19:52 ` Paul Brook
2009-07-29 19:56 ` Filip Navara
2009-07-29 20:05 ` Paul Brook
2009-07-29 20:14 ` Gleb Natapov
2009-07-30 12:14 ` Stefano Stabellini
2009-07-30 12:27 ` Paul Brook
2009-07-29 19:33 ` Anthony Liguori
2009-07-29 19:44 ` [Qemu-devel] " Juan Quintela
2009-07-29 20:05 ` Anthony Liguori
2009-07-29 20:09 ` Juan Quintela
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=20090729135057.GY30449@redhat.com \
--to=gleb@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).