Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 net/vde.c |   37 +++++++++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/net/vde.c b/net/vde.c
index 8e60f68..35e8113 100644
--- a/net/vde.c
+++ b/net/vde.c
@@ -110,20 +110,41 @@ static int net_vde_init(VLANState *vlan, const char 
*model,
     return 0;
 }
 
-int net_init_vde(QemuOpts *opts, const NetClientOptions *new_opts,
+int net_init_vde(QemuOpts *old_opts, const NetClientOptions *opts,
                  const char *name, VLANState *vlan)
 {
-    const char *sock;
-    const char *group;
     int port, mode;
 
-    sock  = qemu_opt_get(opts, "sock");
-    group = qemu_opt_get(opts, "group");
+    const NetdevVdeOptions *vde;
 
-    port = qemu_opt_get_number(opts, "port", 0);
-    mode = qemu_opt_get_number(opts, "mode", 0700);
+    assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VDE);
+    vde = opts->vde;
 
-    if (net_vde_init(vlan, "vde", name, sock, port, group, mode) == -1) {
+    if (vde->has_port) {
+        if (vde->port > INT_MAX) {
+            error_report("invalid port: %"PRId64, vde->port);
+            return -1;
+        }
+        port = vde->port;
+    }
+    else {
+        port = 0;
+    }
+
+    if (vde->has_mode) {
+        if (vde->mode > INT_MAX) {
+            error_report("invalid mode: %"PRId64, vde->mode);
+            return -1;
+        }
+        mode = vde->mode;
+    }
+    else {
+        mode = 0700;
+    }
+
+    /* missing optional values have been initialized to "all bits zero" */
+    if (net_vde_init(vlan, "vde", name, vde->sock, port, vde->group, mode) ==
+         -1) {
         return -1;
     }
 
-- 
1.7.1



Reply via email to