diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2009-09-24 11:16:01 -0300 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-05 09:32:44 -0500 |
commit | 0148fde54c2478ea8a47c8dbfe4c0fb8bda4d996 (patch) | |
tree | 8716c085665e653cc45ac7344460f19eff37fc7d /hw/pci-hotplug.c | |
parent | a9796703447fc5c5691b749915f0f627f47f05a9 (diff) |
Fix exit on 'pci_add' Monitor command
If the user issues one of the following commands to the Monitor:
pci_add pci_addr=auto nic model=None
pci_add pci_addr=auto nic model=?
QEMU will exit, because the function used to perform sanity
checks (qemu_check_nic_model_list()) exits on error.
This function is used by the startup code, where it makes
sense to exit on error, but in the Monitor it doesn't.
Changing qemu_check_nic_model_list() to not exit on error
is not possible though, as it's used by the board init
code (the PC one), where all board specific code must have
void return.
The way I've chosen to fix this was to introduce a new function
called pci_nic_supported(), which checks if the NIC is supported
and returns true or false accordingly.
The new function is used only by the Monitor, it performs the
necessary check and returns an error in case the NIC is not
supported, thus qemu_check_nic_model_list()'s exit is never trigged.
The following should be observed:
1. Only the specified NIC is checked, the default one is assumed
to be supported
2. The NIC query command (model=?) won't work with pci_add, the
right way to do this with the Monitor is to add a new command
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/pci-hotplug.c')
-rw-r--r-- | hw/pci-hotplug.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index f3dc42103d..89974a0668 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); } |