@@ -34,6 +34,20 @@
#include "blockdev.h"
#include "error.h"
+static int read_pci_devaddr(Monitor *mon, const char *addr, unsigned int *domp,
+ unsigned int *busp, unsigned *slotp)
+{
+ /* strip legacy tag */
+ if (!strncmp(addr, "pci_addr=", 9)) {
+ addr += 9;
+ }
+ if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
+ monitor_printf(mon, "Invalid pci address\n");
+ return -1;
+ }
+ return 0;
+}
+
#if defined(TARGET_I386)
static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
const char *devaddr,
@@ -115,7 +129,7 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict,
switch (type) {
case IF_SCSI:
- if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
+ if (read_pci_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
goto err;
}
dev = pci_find_device(pci_find_root_bus(dom), pci_bus,
@@ -261,7 +275,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
unsigned slot;
Error *local_err = NULL;
- if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
+ if (read_pci_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
return -1;
}
@@ -512,9 +512,8 @@ static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
* Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
* [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
*/
-static int pci_parse_devaddr(const char *addr, unsigned int *domp,
- unsigned int *busp, unsigned int *slotp,
- unsigned int *funcp)
+int pci_parse_devaddr(const char *addr, unsigned int *domp, unsigned int *busp,
+ unsigned int *slotp, unsigned int *funcp)
{
const char *p;
char *e;
@@ -572,20 +571,6 @@ static int pci_parse_devaddr(const char *addr, unsigned int *domp,
return 0;
}
-int pci_read_devaddr(Monitor *mon, const char *addr, unsigned int *domp,
- unsigned int *busp, unsigned *slotp)
-{
- /* strip legacy tag */
- if (!strncmp(addr, "pci_addr=", 9)) {
- addr += 9;
- }
- if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
- monitor_printf(mon, "Invalid pci address\n");
- return -1;
- }
- return 0;
-}
-
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
{
unsigned int dom, bus;
@@ -340,8 +340,8 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
int pci_qdev_find_device(const char *id, PCIDevice **pdev);
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
-int pci_read_devaddr(Monitor *mon, const char *addr, unsigned int *domp,
- unsigned int *busp, unsigned *slotp);
+int pci_parse_devaddr(const char *addr, unsigned int *domp, unsigned int *busp,
+ unsigned int *slotp, unsigned int *funcp);
void pci_device_deassert_intx(PCIDevice *dev);
The latter is an internal helper for PCI hotplug. So move it where it belongs - before someone misuses it - and export the more versatile pci_parse_devaddr instead. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- hw/pci-hotplug.c | 18 ++++++++++++++++-- hw/pci.c | 19 ++----------------- hw/pci.h | 4 ++-- 3 files changed, 20 insertions(+), 21 deletions(-)