aboutsummaryrefslogtreecommitdiff
path: root/hw/pci-hotplug.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/pci-hotplug.c')
-rw-r--r--hw/pci-hotplug.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index 0fb96f06fd..bd82c6aab7 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -254,7 +254,7 @@ void pci_device_hot_add_print(Monitor *mon, const QObject *data)
*
* { "domain": 0, "bus": 0, "slot": 5, "function": 0 }
*/
-void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
+int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
PCIDevice *dev = NULL;
const char *pci_addr = qdict_get_str(qdict, "pci_addr");
@@ -273,43 +273,49 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
if (!strcmp(pci_addr, "auto"))
pci_addr = NULL;
- if (strcmp(type, "nic") == 0)
+ if (strcmp(type, "nic") == 0) {
dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);
- else if (strcmp(type, "storage") == 0)
+ } else if (strcmp(type, "storage") == 0) {
dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);
- else
+ } else {
monitor_printf(mon, "invalid type: %s\n", type);
+ return -1;
+ }
if (dev) {
*ret_data =
qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, "
"'function': %d }", pci_bus_num(dev->bus),
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
- } else
+ } else {
monitor_printf(mon, "failed to add %s\n", opts);
+ return -1;
+ }
+
+ return 0;
}
#endif
-void pci_device_hot_remove(Monitor *mon, const char *pci_addr)
+int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
{
PCIDevice *d;
int dom, bus;
unsigned slot;
if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
- return;
+ return -1;
}
d = pci_find_device(pci_find_root_bus(0), bus, slot, 0);
if (!d) {
monitor_printf(mon, "slot %d empty\n", slot);
- return;
+ return -1;
}
- qdev_unplug(&d->qdev);
+ return qdev_unplug(&d->qdev);
}
-void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict,
- QObject **ret_data)
+int do_pci_device_hot_remove(Monitor *mon, const QDict *qdict,
+ QObject **ret_data)
{
- pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"));
+ return pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"));
}