]> Git Repo - qemu.git/commitdiff
net: Fix hotplug with pci_add
authorAmit Shah <[email protected]>
Tue, 8 Jun 2010 15:43:58 +0000 (21:13 +0530)
committerMichael S. Tsirkin <[email protected]>
Wed, 9 Jun 2010 09:58:55 +0000 (12:58 +0300)
The correct model type wasn't getting added when hotplugging nics with
pci_add.

Testcase: start VM with default nic type. In the qemu_monitor:

(qemu) pci_add auto nic model=virtio

This results in a nic hot-plug of the same nic type as the default.

This was broken in 5294e2c774f120e10b44652ac143abda356f44eb

Also changes the behaviour where no .init is defined for a
net_client_type. Previously, 0 was returned, which indicated the init
was successful and that 0 was the index into the nd_tables[] array.
Return -1, indicating unsuccessful init, in such a case.

Signed-off-by: Amit Shah <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
net.c

diff --git a/net.c b/net.c
index 378edfccd0f2d5607e87a1e1cfa370cc87005dd3..22f5cf1f329785d129f22dfb596c33c0f9737e5f 100644 (file)
--- a/net.c
+++ b/net.c
@@ -1106,6 +1106,7 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
     for (i = 0; net_client_types[i].type != NULL; i++) {
         if (!strcmp(net_client_types[i].type, type)) {
             VLANState *vlan = NULL;
+            int ret;
 
             if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) {
                 return -1;
@@ -1118,14 +1119,16 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
                 vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);
             }
 
+            ret = -1;
             if (net_client_types[i].init) {
-                if (net_client_types[i].init(opts, mon, name, vlan) < 0) {
+                ret = net_client_types[i].init(opts, mon, name, vlan);
+                if (ret < 0) {
                     /* TODO push error reporting into init() methods */
                     qerror_report(QERR_DEVICE_INIT_FAILED, type);
                     return -1;
                 }
             }
-            return 0;
+            return ret;
         }
     }
 
This page took 0.02818 seconds and 4 git commands to generate.