From f7e7119fecbce280e7ee45364260fb6e4d58d49a Mon Sep 17 00:00:00 2001 From: Dmitry Konishchev
Date: Wed, 16 Mar 2011 12:26:09 +0300 Subject: [PATCH 1/2] QMP: Return pci address in pci_add command --- hw/pci-hotplug.c | 17 +++++++++++++++-- qemu-monitor.hx | 4 +++- sysemu.h | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 6b2de85..23c105f 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -32,6 +32,7 @@ #include "virtio-blk.h" #include "qemu-config.h" #include "device-assignment.h" +#include "qjson.h" #if defined(TARGET_I386) static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, @@ -247,7 +248,7 @@ static PCIDevice *qemu_pci_hot_assign_device(Monitor *mon, } #endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */ -void pci_device_hot_add(Monitor *mon, const QDict *qdict) +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"); @@ -283,8 +284,20 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict) pci_find_domain(dev->bus), pci_bus_num(dev->bus), PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); - } else + + char format[] = "{ 'domain': '%x', 'bus': '%x', 'slot': '%x' }"; + char buf[sizeof format + 3 * sizeof(int) * 2]; + snprintf(buf, sizeof buf, format, + pci_find_domain(dev->bus), pci_bus_num(dev->bus), PCI_SLOT(dev->devfn)); + + *ret_data = qobject_from_json(buf); + assert(*ret_data != NULL); + } else { monitor_printf(mon, "failed to add %s\n", opts); + qerror_report(QERR_UNDEFINED_ERROR); + } + + return !dev; } #endif diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 595d362..8b1415d 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -1149,7 +1149,8 @@ ETEXI .args_type = "pci_addr:s,type:s,opts:s?", .params = "auto|[[