[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Fix CDROM change

From: Anthony Liguori
Subject: [Qemu-devel] [PATCH] Fix CDROM change
Date: Sun, 17 Dec 2006 16:55:46 -0600
User-agent: Thunderbird (X11/20061115)

Fabrice's 'better support of removable media" removed the cdrom_change_cb() from ide.c mentioning that it wasn't needed anymore.

I don't see anywhere else in the IDE code that triggers an update of nb_sectors though so I think it's still needed. Currently, if you do:

change cdrom /path/to/cdrom1.iso
eject cdrom
change cdrom /path/to/cdrom2.iso

Everything works up to the second change. The guest never sees the new cdrom. The follow patch adds back the cdrom_change_cb() and now things work like they used to. If there's a better way to do this, I'll be happy to submit a new patch.


Anthony Liguori
diff -r 1e346ef889b3 hw/ide.c
--- a/hw/ide.c  Sun Dec 17 10:38:27 2006 -0600
+++ b/hw/ide.c  Sun Dec 17 16:49:06 2006 -0600
@@ -1479,6 +1479,17 @@ static void ide_atapi_cmd(IDEState *s)
+/* called when the inserted state of the media has changed */
+static void cdrom_change_cb(void *opaque)
+    IDEState *s = opaque;
+    int64_t nb_sectors;
+    /* XXX: send interrupt too */
+    bdrv_get_geometry(s->bs, &nb_sectors);
+    s->nb_sectors = nb_sectors;
 static void ide_cmd_lba48_transform(IDEState *s, int lba48)
@@ -2111,6 +2122,7 @@ static void ide_init2(IDEState *ide_stat
             if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
                 s->is_cdrom = 1;
+               bdrv_set_change_cb(s->bs, cdrom_change_cb, s);
         s->drive_serial = drive_serial++;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]