]> git.proxmox.com Git - mirror_qemu.git/blobdiff - net.c
qdev: implement qdev_prop_set_bit().
[mirror_qemu.git] / net.c
diff --git a/net.c b/net.c
index 22f5cf1f329785d129f22dfb596c33c0f9737e5f..8ddf872a6f1b896c5db2f49a07f950c6a2c89d93 100644 (file)
--- a/net.c
+++ b/net.c
@@ -1119,7 +1119,7 @@ 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;
+            ret = 0;
             if (net_client_types[i].init) {
                 ret = net_client_types[i].init(opts, mon, name, vlan);
                 if (ret < 0) {
@@ -1197,18 +1197,6 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict)
     qemu_del_vlan_client(vc);
 }
 
-/**
- * do_netdev_add(): Add a host network device
- *
- * Argument qdict contains
- * - "type": the device type, "tap", "user", ...
- * - "id": the device's ID (must be unique)
- * - device options
- *
- * Example:
- *
- * { "type": "user", "id": "netdev1", "hostname": "a-guest" }
- */
 int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     QemuOpts *opts;
@@ -1220,19 +1208,13 @@ int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
     }
 
     res = net_client_init(mon, opts, 1);
+    if (res < 0) {
+        qemu_opts_del(opts);
+    }
+
     return res;
 }
 
-/**
- * do_netdev_del(): Delete a host network device
- *
- * Argument qdict contains
- * - "id": the device's ID
- *
- * Example:
- *
- * { "id": "netdev1" }
- */
 int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     const char *id = qdict_get_str(qdict, "id");
@@ -1243,10 +1225,6 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
         qerror_report(QERR_DEVICE_NOT_FOUND, id);
         return -1;
     }
-    if (vc->peer) {
-        qerror_report(QERR_DEVICE_IN_USE, id);
-        return -1;
-    }
     qemu_del_vlan_client(vc);
     qemu_opts_del(qemu_opts_find(&qemu_netdev_opts, id));
     return 0;