diff options
author | Jan Kiszka <jan.kiszka@web.de> | 2009-06-26 00:04:00 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-06-29 14:18:07 -0500 |
commit | e9283f8b88eb6054ac032f3d9b773e80d842c0cf (patch) | |
tree | c081d619584bf9060bd4a7b37f0484cbb3a6ac0a /hw | |
parent | 3b88e52b41fe77728b4accb68e14bed98bdc75d3 (diff) |
monitor: Drop pci_addr prefix from hotplug commands
The "pci_addr=" prefix currently required by pci_add/remove and
drive_add has no practical use. Drop it, but still silently accept it
for backward compatibility.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/pci-hotplug.c | 22 | ||||
-rw-r--r-- | hw/pci.c | 16 | ||||
-rw-r--r-- | hw/pci.h | 3 |
3 files changed, 21 insertions, 20 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 952e27a9f7..f7d38a70d6 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -56,8 +56,7 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts) int success = 0; PCIDevice *dev; - if (pci_read_devaddr(pci_addr, &dom, &pci_bus, &slot)) { - monitor_printf(mon, "Invalid pci address\n"); + if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) { return; } @@ -148,21 +147,19 @@ void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type, const char *opts) { PCIDevice *dev = NULL; - const char *devaddr = NULL; - char buf[32]; - if (!get_param_value(buf, sizeof(buf), "pci_addr", pci_addr)) { - monitor_printf(mon, "Invalid pci address\n"); - return; + /* strip legacy tag */ + if (!strncmp(pci_addr, "pci_addr=", 9)) { + pci_addr += 9; } - if (strcmp(buf, "auto")) - devaddr = buf; + if (!strcmp(pci_addr, "auto")) + pci_addr = NULL; if (strcmp(type, "nic") == 0) - dev = qemu_pci_hot_add_nic(mon, devaddr, opts); + dev = qemu_pci_hot_add_nic(mon, pci_addr, opts); else if (strcmp(type, "storage") == 0) - dev = qemu_pci_hot_add_storage(mon, devaddr, opts); + dev = qemu_pci_hot_add_storage(mon, pci_addr, opts); else monitor_printf(mon, "invalid type: %s\n", type); @@ -183,8 +180,7 @@ void pci_device_hot_remove(Monitor *mon, const char *pci_addr) int dom, bus; unsigned slot; - if (pci_read_devaddr(pci_addr, &dom, &bus, &slot)) { - monitor_printf(mon, "Invalid pci address\n"); + if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) { return; } @@ -232,14 +232,18 @@ static int pci_parse_devaddr(const char *addr, int *domp, int *busp, unsigned *s return 0; } -int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *slotp) +int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp, + unsigned *slotp) { - char devaddr[32]; - - if (!get_param_value(devaddr, sizeof(devaddr), "pci_addr", addr)) + /* strip legacy tag */ + if (!strncmp(addr, "pci_addr=", 9)) { + addr += 9; + } + if (pci_parse_devaddr(addr, domp, busp, slotp)) { + monitor_printf(mon, "Invalid pci address\n"); return -1; - - return pci_parse_devaddr(devaddr, domp, busp, slotp); + } + return 0; } static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) @@ -252,7 +252,8 @@ 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); -int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *slotp); +int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp, + unsigned *slotp); void pci_info(Monitor *mon); PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did, |