diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index f3dc42103dc4efade027e711b0a2c414ef701e12..89974a0668939ac5f1e1f617f0b98bafb07c6997 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -46,6 +46,10 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon, monitor_printf(mon, "Parameter addr not supported\n"); return NULL; } + + if (nd_table[ret].model && !pci_nic_supported(nd_table[ret].model)) + return NULL; + return pci_nic_init(&nd_table[ret], "rtl8139", devaddr); } diff --git a/hw/pci.c b/hw/pci.c index c46410aae3cefb7550014028db1ed40b199fcc10..c656bd047c8831d92a96f24367348ae25071ddb4 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -806,6 +806,17 @@ static const char * const pci_nic_names[] = { NULL }; +int pci_nic_supported(const char *model) +{ + int i; + + for (i = 0; pci_nic_names[i]; i++) + if (strcmp(model, pci_nic_names[i]) == 0) + return 1; + + return 0; +} + /* Initialize a PCI NIC. */ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, const char *default_devaddr) diff --git a/hw/pci.h b/hw/pci.h index caba5c8518218faed08169befba6f05e877d694d..ba748ff9cda2166b65767d0607313099a9e4a82c 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -252,6 +252,7 @@ PCIBus *pci_register_bus(DeviceState *parent, const char *name, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, int devfn_min, int nirq); +int pci_nic_supported(const char *model); PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, const char *default_devaddr); void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);