From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gw4vO-0000nr-9k for qemu-devel@nongnu.org; Sun, 17 Dec 2006 17:56:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gw4vM-0000kk-Cs for qemu-devel@nongnu.org; Sun, 17 Dec 2006 17:56:05 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gw4vM-0000kW-98 for qemu-devel@nongnu.org; Sun, 17 Dec 2006 17:56:04 -0500 Received: from [128.83.139.10] (helo=mail.cs.utexas.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Gw4vM-0007Sc-8W for qemu-devel@nongnu.org; Sun, 17 Dec 2006 17:56:04 -0500 Message-ID: <4585CAF2.9030502@cs.utexas.edu> Date: Sun, 17 Dec 2006 16:55:46 -0600 From: Anthony Liguori MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090901030109000907060703" Subject: [Qemu-devel] [PATCH] Fix CDROM change Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Fabrice Bellard This is a multi-part message in MIME format. --------------090901030109000907060703 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------090901030109000907060703 Content-Type: text/x-patch; name="qemu-cdrom-change.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-cdrom-change.diff" 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++; --------------090901030109000907060703--