aboutsummaryrefslogtreecommitdiff
path: root/hw/pci-hotplug.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2009-09-25 03:53:49 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-05 09:32:53 -0500
commit49bd1458da8909434eb83c5cda472c63ff6a529c (patch)
tree85c55b21db44f91b06201d9c16911c3c946b5fab /hw/pci-hotplug.c
parent48042d861e364c04d0431cc6f52594ea00267c80 (diff)
Fix pci_add storage not to exit on bad first argument
Monitor command "pci_add ADDR storage ..." does its work in qemu_pci_hot_add_nic(). It called pci_create(..., ADDR) to create the device. That's wrong, because pci_create() terminates the program when ADDR is invalid. Use pci_get_bus_devfn() and pci_create_noinit() instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pci-hotplug.c')
-rw-r--r--hw/pci-hotplug.c12
1 files changed, 10 insertions, 2 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: