From 29b358f93a48a415853d11fc9b02f711b5ec8f76 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 6 Jun 2013 18:48:51 +1000 Subject: pci: Add root bus parameter to pci_nic_init() At present, pci_nic_init() and pci_nic_init_nofail() assume that they will only create a NIC under the primary PCI root. As we add support for multiple PCI roots, that may no longer be the case. This patch adds a root bus parameter to pci_nic_init() (and updates callers accordingly) to allow the machine init code using it to specify the right PCI root for NICs created by old-style -net nic parameters. NICs created new-style, with -device can of course be put anywhere. Signed-off-by: David Gibson Signed-off-by: Michael S. Tsirkin --- hw/pci/pci-hotplug-old.c | 3 ++- hw/pci/pci.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'hw/pci') diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c index e92d6467be..807260cce9 100644 --- a/hw/pci/pci-hotplug-old.c +++ b/hw/pci/pci-hotplug-old.c @@ -92,7 +92,8 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, monitor_printf(mon, "Parameter addr not supported\n"); return NULL; } - return pci_nic_init(&nd_table[ret], "rtl8139", devaddr); + return pci_nic_init(&nd_table[ret], pci_find_primary_bus(), + "rtl8139", devaddr); } static int scsi_hot_add(Monitor *mon, DeviceState *adapter, diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c4f63ad9f3..2f2db0f8df 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1575,7 +1575,8 @@ static const char * const pci_nic_names[] = { /* Initialize a PCI NIC. */ /* FIXME callers should check for failure, but don't */ -PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, +PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus, + const char *default_model, const char *default_devaddr) { const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr; @@ -1589,7 +1590,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, if (i < 0) return NULL; - bus = pci_get_bus_devfn(&devfn, pci_find_primary_bus(), devaddr); + bus = pci_get_bus_devfn(&devfn, rootbus, devaddr); if (!bus) { error_report("Invalid PCI device address %s for device %s", devaddr, pci_nic_names[i]); @@ -1604,7 +1605,8 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, return pci_dev; } -PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model, +PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus, + const char *default_model, const char *default_devaddr) { PCIDevice *res; @@ -1612,7 +1614,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model, if (qemu_show_nic_models(nd->model, pci_nic_models)) exit(0); - res = pci_nic_init(nd, default_model, default_devaddr); + res = pci_nic_init(nd, rootbus, default_model, default_devaddr); if (!res) exit(1); return res; -- cgit v1.2.3