qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix CDROM change
@ 2006-12-17 22:55 Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2006-12-17 22:55 UTC (permalink / raw)
  To: qemu-devel, Fabrice Bellard

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

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.

Regards,

Anthony Liguori

[-- Attachment #2: qemu-cdrom-change.diff --]
[-- Type: text/x-patch, Size: 899 bytes --]

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)
                             ASC_ILLEGAL_OPCODE);
         break;
     }
+}
+
+/* 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++;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-12-17 22:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-17 22:55 [Qemu-devel] [PATCH] Fix CDROM change Anthony Liguori

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).