From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUi4s-0002mM-G3 for qemu-devel@nongnu.org; Wed, 04 Feb 2009 08:46:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUi4q-0002li-Lc for qemu-devel@nongnu.org; Wed, 04 Feb 2009 08:46:06 -0500 Received: from [199.232.76.173] (port=37312 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUi4q-0002lX-Dg for qemu-devel@nongnu.org; Wed, 04 Feb 2009 08:46:04 -0500 Received: from mx2.redhat.com ([66.187.237.31]:34128) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUi4p-0000dt-RD for qemu-devel@nongnu.org; Wed, 04 Feb 2009 08:46:04 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n14Dk3EH010633 for ; Wed, 4 Feb 2009 08:46:03 -0500 Message-Id: <20090204133923.697811481@localhost.localdomain> References: <20090204133303.113145633@localhost.localdomain> Date: Wed, 04 Feb 2009 11:33:09 -0200 From: Marcelo Tosatti Content-Disposition: inline; filename=record-pcidev-on-bdrv Subject: [Qemu-devel] [patch 06/18] qemu: record devfn on block driver instance 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 Cc: Marcelo Tosatti Record PCIDev on the BlockDriverState structure to locate for release on hot-removal. Signed-off-by: Marcelo Tosatti Index: trunk/block_int.h =================================================================== --- trunk.orig/block_int.h +++ trunk/block_int.h @@ -127,6 +127,7 @@ struct BlockDriverState { int type; char device_name[32]; BlockDriverState *next; + void *private; }; struct BlockDriverAIOCB { Index: trunk/hw/ide.c =================================================================== --- trunk.orig/hw/ide.c +++ trunk/hw/ide.c @@ -28,6 +28,7 @@ #include "scsi-disk.h" #include "pcmcia.h" #include "block.h" +#include "block_int.h" #include "qemu-timer.h" #include "sysemu.h" #include "ppc_mac.h" @@ -3410,6 +3411,7 @@ void pci_piix3_ide_init(PCIBus *bus, Blo { PCIIDEState *d; uint8_t *pci_conf; + int i; /* register a function 1 of PIIX3 */ d = (PCIIDEState *)pci_register_device(bus, "PIIX3 IDE", @@ -3436,6 +3438,10 @@ void pci_piix3_ide_init(PCIBus *bus, Blo ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6); ide_init_ioport(&d->ide_if[2], 0x170, 0x376); + for (i = 0; i < 4; i++) + if (hd_table[i]) + hd_table[i]->private = &d->dev; + register_savevm("ide", 0, 2, pci_ide_save, pci_ide_load, d); } Index: trunk/hw/lsi53c895a.c =================================================================== --- trunk.orig/hw/lsi53c895a.c +++ trunk/hw/lsi53c895a.c @@ -13,6 +13,7 @@ #include "hw.h" #include "pci.h" #include "scsi-disk.h" +#include "block_int.h" //#define DEBUG_LSI //#define DEBUG_LSI_REG @@ -1958,6 +1959,7 @@ void lsi_scsi_attach(void *opaque, Block s->scsi_dev[id] = scsi_generic_init(bd, 1, lsi_command_complete, s); if (s->scsi_dev[id] == NULL) s->scsi_dev[id] = scsi_disk_init(bd, 1, lsi_command_complete, s); + bd->private = &s->pci_dev; } void *lsi_scsi_init(PCIBus *bus, int devfn) Index: trunk/hw/virtio-blk.c =================================================================== --- trunk.orig/hw/virtio-blk.c +++ trunk/hw/virtio-blk.c @@ -315,6 +315,7 @@ void *virtio_blk_init(PCIBus *bus, Block s->vdev.reset = virtio_blk_reset; s->bs = bs; s->rq = NULL; + bs->private = &s->vdev.pci_dev; bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); bdrv_set_geometry_hint(s->bs, cylinders, heads, secs); --