Fix CDROM change
PATCH 1/1 Fix CDROM change
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
hw/ide.c +12 -0
@@ -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++;