From 72da42085924f65c78e6ec478373f51a9e49e48d Mon Sep 17 00:00:00 2001 From: aliguori Date: Wed, 11 Feb 2009 15:19:52 +0000 Subject: qemu: return PCIDevice on net device init and record devfn (Marcelo Tosatti) Change the PCI network drivers init functions to return the PCIDev, to inform which slot has been hot-plugged. Also record PCIDevice structure on NICInfo to locate for release on hot-removal. Signed-off-by: Marcelo Tosatti Signed-off-by: Anthony Liguori git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6593 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/pci.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'hw/pci.c') diff --git a/hw/pci.c b/hw/pci.c index d0e16fe44f..b88ed3527b 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -662,7 +662,7 @@ static const char * const pci_nic_models[] = { NULL }; -typedef void (*PCINICInitFn)(PCIBus *, NICInfo *, int); +typedef PCIDevice *(*PCINICInitFn)(PCIBus *, NICInfo *, int); static PCINICInitFn pci_nic_init_fns[] = { pci_ne2000_init, @@ -677,16 +677,23 @@ static PCINICInitFn pci_nic_init_fns[] = { }; /* Initialize a PCI NIC. */ -void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn, +PCIDevice *pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn, const char *default_model) { + PCIDevice *pci_dev; int i; qemu_check_nic_model_list(nd, pci_nic_models, default_model); for (i = 0; pci_nic_models[i]; i++) - if (strcmp(nd->model, pci_nic_models[i]) == 0) - pci_nic_init_fns[i](bus, nd, devfn); + if (strcmp(nd->model, pci_nic_models[i]) == 0) { + pci_dev = pci_nic_init_fns[i](bus, nd, devfn); + if (pci_dev) + nd->private = pci_dev; + return pci_dev; + } + + return NULL; } typedef struct { -- cgit 1.4.1