diff options
-rw-r--r-- | hw/pci-hotplug.c | 12 | ||||
-rw-r--r-- | hw/pci.c | 2 | ||||
-rw-r--r-- | hw/pci.h | 1 |
3 files changed, 12 insertions, 3 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index d40a3bd0cd..d02f73cd70 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -114,6 +114,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, DriveInfo *dinfo = NULL; int type = -1; char buf[128]; + PCIBus *bus; + int devfn; if (get_param_value(buf, sizeof(buf), "if", opts)) { if (!strcmp(buf, "scsi")) @@ -141,16 +143,22 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, dinfo = NULL; } + bus = pci_get_bus_devfn(&devfn, devaddr); + if (!bus) { + monitor_printf(mon, "Invalid PCI device address %s\n", devaddr); + return NULL; + } + switch (type) { case IF_SCSI: - dev = pci_create("lsi53c895a", devaddr); + dev = pci_create_noinit(bus, devfn, "lsi53c895a"); break; case IF_VIRTIO: if (!dinfo) { monitor_printf(mon, "virtio requires a backing file/device.\n"); return NULL; } - dev = pci_create("virtio-blk-pci", devaddr); + dev = pci_create_noinit(bus, devfn, "virtio-blk-pci"); qdev_prop_set_drive(&dev->qdev, "drive", dinfo); break; default: @@ -317,7 +317,7 @@ int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp, return 0; } -static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) +PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) { int dom, bus; unsigned slot; @@ -262,6 +262,7 @@ int pci_bus_num(PCIBus *s); void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d)); PCIBus *pci_find_bus(int bus_num); PCIDevice *pci_find_device(int bus_num, int slot, int function); +PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr); int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp, unsigned *slotp); |