Commit e9283f8b88eb6054ac032f3d9b773e80d842c0cf

Authored by Jan Kiszka
Committed by Anthony Liguori
1 parent 3b88e52b

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>
hw/pci-hotplug.c
@@ -56,8 +56,7 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts) @@ -56,8 +56,7 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
56 int success = 0; 56 int success = 0;
57 PCIDevice *dev; 57 PCIDevice *dev;
58 58
59 - if (pci_read_devaddr(pci_addr, &dom, &pci_bus, &slot)) {  
60 - monitor_printf(mon, "Invalid pci address\n"); 59 + if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
61 return; 60 return;
62 } 61 }
63 62
@@ -148,21 +147,19 @@ void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type, @@ -148,21 +147,19 @@ void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type,
148 const char *opts) 147 const char *opts)
149 { 148 {
150 PCIDevice *dev = NULL; 149 PCIDevice *dev = NULL;
151 - const char *devaddr = NULL;  
152 - char buf[32];  
153 150
154 - if (!get_param_value(buf, sizeof(buf), "pci_addr", pci_addr)) {  
155 - monitor_printf(mon, "Invalid pci address\n");  
156 - return; 151 + /* strip legacy tag */
  152 + if (!strncmp(pci_addr, "pci_addr=", 9)) {
  153 + pci_addr += 9;
157 } 154 }
158 155
159 - if (strcmp(buf, "auto"))  
160 - devaddr = buf; 156 + if (!strcmp(pci_addr, "auto"))
  157 + pci_addr = NULL;
161 158
162 if (strcmp(type, "nic") == 0) 159 if (strcmp(type, "nic") == 0)
163 - dev = qemu_pci_hot_add_nic(mon, devaddr, opts); 160 + dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);
164 else if (strcmp(type, "storage") == 0) 161 else if (strcmp(type, "storage") == 0)
165 - dev = qemu_pci_hot_add_storage(mon, devaddr, opts); 162 + dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);
166 else 163 else
167 monitor_printf(mon, "invalid type: %s\n", type); 164 monitor_printf(mon, "invalid type: %s\n", type);
168 165
@@ -183,8 +180,7 @@ void pci_device_hot_remove(Monitor *mon, const char *pci_addr) @@ -183,8 +180,7 @@ void pci_device_hot_remove(Monitor *mon, const char *pci_addr)
183 int dom, bus; 180 int dom, bus;
184 unsigned slot; 181 unsigned slot;
185 182
186 - if (pci_read_devaddr(pci_addr, &dom, &bus, &slot)) {  
187 - monitor_printf(mon, "Invalid pci address\n"); 183 + if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
188 return; 184 return;
189 } 185 }
190 186
hw/pci.c
@@ -232,14 +232,18 @@ static int pci_parse_devaddr(const char *addr, int *domp, int *busp, unsigned *s @@ -232,14 +232,18 @@ static int pci_parse_devaddr(const char *addr, int *domp, int *busp, unsigned *s
232 return 0; 232 return 0;
233 } 233 }
234 234
235 -int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *slotp) 235 +int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
  236 + unsigned *slotp)
236 { 237 {
237 - char devaddr[32];  
238 -  
239 - if (!get_param_value(devaddr, sizeof(devaddr), "pci_addr", addr)) 238 + /* strip legacy tag */
  239 + if (!strncmp(addr, "pci_addr=", 9)) {
  240 + addr += 9;
  241 + }
  242 + if (pci_parse_devaddr(addr, domp, busp, slotp)) {
  243 + monitor_printf(mon, "Invalid pci address\n");
240 return -1; 244 return -1;
241 -  
242 - return pci_parse_devaddr(devaddr, domp, busp, slotp); 245 + }
  246 + return 0;
243 } 247 }
244 248
245 static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr) 249 static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
hw/pci.h
@@ -252,7 +252,8 @@ void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d)); @@ -252,7 +252,8 @@ void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
252 PCIBus *pci_find_bus(int bus_num); 252 PCIBus *pci_find_bus(int bus_num);
253 PCIDevice *pci_find_device(int bus_num, int slot, int function); 253 PCIDevice *pci_find_device(int bus_num, int slot, int function);
254 254
255 -int pci_read_devaddr(const char *addr, int *domp, int *busp, unsigned *slotp); 255 +int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
  256 + unsigned *slotp);
256 257
257 void pci_info(Monitor *mon); 258 void pci_info(Monitor *mon);
258 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did, 259 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did,
qemu-monitor.hx
@@ -493,7 +493,7 @@ Set maximum tolerated downtime (in seconds) for migration. @@ -493,7 +493,7 @@ Set maximum tolerated downtime (in seconds) for migration.
493 ETEXI 493 ETEXI
494 494
495 #if defined(TARGET_I386) 495 #if defined(TARGET_I386)
496 - { "drive_add", "ss", drive_hot_add, "pci_addr=[[<domain>:]<bus>:]<slot>\n" 496 + { "drive_add", "ss", drive_hot_add, "[[<domain>:]<bus>:]<slot>\n"
497 "[file=file][,if=type][,bus=n]\n" 497 "[file=file][,if=type][,bus=n]\n"
498 "[,unit=m][,media=d][index=i]\n" 498 "[,unit=m][,media=d][index=i]\n"
499 "[,cyls=c,heads=h,secs=s[,trans=t]]\n" 499 "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
@@ -506,7 +506,7 @@ Add drive to PCI storage controller. @@ -506,7 +506,7 @@ Add drive to PCI storage controller.
506 ETEXI 506 ETEXI
507 507
508 #if defined(TARGET_I386) 508 #if defined(TARGET_I386)
509 - { "pci_add", "sss", pci_device_hot_add, "pci_addr=auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" }, 509 + { "pci_add", "sss", pci_device_hot_add, "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" },
510 #endif 510 #endif
511 STEXI 511 STEXI
512 @item pci_add 512 @item pci_add
@@ -514,7 +514,7 @@ Hot-add PCI device. @@ -514,7 +514,7 @@ Hot-add PCI device.
514 ETEXI 514 ETEXI
515 515
516 #if defined(TARGET_I386) 516 #if defined(TARGET_I386)
517 - { "pci_del", "s", pci_device_hot_remove, "pci_addr=[[<domain>:]<bus>:]<slot>", "hot remove PCI device" }, 517 + { "pci_del", "s", pci_device_hot_remove, "[[<domain>:]<bus>:]<slot>", "hot remove PCI device" },
518 #endif 518 #endif
519 STEXI 519 STEXI
520 @item pci_del 520 @item pci_del