From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JZAtS-0007Ox-UH for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:16:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JZAtS-0007Ol-Ah for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:16:14 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JZAtS-0007Oi-30 for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:16:14 -0400 Received: from mx1.redhat.com ([66.187.233.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JZAtR-00042i-Oy for qemu-devel@nongnu.org; Tue, 11 Mar 2008 16:16:13 -0400 Message-Id: <20080311201417.923099366@localhost.localdomain> References: <20080311201151.959635433@localhost.localdomain> Date: Tue, 11 Mar 2008 17:12:00 -0300 From: Marcelo Tosatti Content-Disposition: inline; filename=pci-info Subject: [Qemu-devel] [patch 09/24] QEMU/KVM: 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, kvm-devel@lists.sourceforge.net Cc: aliguori@us.ibm.com, Marcelo Tosatti Record devfn on the BlockDriverState structure to locate for release on hot-removal. Signed-off-by: Marcelo Tosatti Index: kvm-userspace.hotplug2/qemu/block_int.h =================================================================== --- kvm-userspace.hotplug2.orig/qemu/block_int.h +++ kvm-userspace.hotplug2/qemu/block_int.h @@ -129,6 +129,8 @@ struct BlockDriverState { int cyls, heads, secs, translation; int type; char device_name[32]; + /* PCI devfn of parent */ + int devfn; BlockDriverState *next; }; Index: kvm-userspace.hotplug2/qemu/hw/lsi53c895a.c =================================================================== --- kvm-userspace.hotplug2.orig/qemu/hw/lsi53c895a.c +++ kvm-userspace.hotplug2/qemu/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 @@ -1845,6 +1846,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->devfn = s->pci_dev.devfn; } void *lsi_scsi_init(PCIBus *bus, int devfn) Index: kvm-userspace.hotplug2/qemu/hw/virtio-blk.c =================================================================== --- kvm-userspace.hotplug2.orig/qemu/hw/virtio-blk.c +++ kvm-userspace.hotplug2/qemu/hw/virtio-blk.c @@ -13,6 +13,7 @@ #include "virtio.h" #include "block.h" +#include "block_int.h" #include "pc.h" /* from Linux's linux/virtio_blk.h */ @@ -156,6 +157,7 @@ void *virtio_blk_init(PCIBus *bus, uint1 s->vdev.update_config = virtio_blk_update_config; s->vdev.get_features = virtio_blk_get_features; s->bs = bs; + bs->devfn = s->vdev.pci_dev.devfn; virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output); Index: kvm-userspace.hotplug2/qemu/hw/ide.c =================================================================== --- kvm-userspace.hotplug2.orig/qemu/hw/ide.c +++ kvm-userspace.hotplug2/qemu/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" @@ -2938,6 +2939,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", @@ -2966,6 +2968,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]->devfn = d->dev.devfn; + register_savevm("ide", 0, 1, pci_ide_save, pci_ide_load, d); } --