Patchwork [RFC,8/9] net: qomify -netdev vde

login
register
mail settings
Submitter Zhiyong Wu
Date March 26, 2012, 5:40 a.m.
Message ID <1332740423-8426-11-git-send-email-zwu.kernel@gmail.com>
Download mbox | patch
Permalink /patch/148640/
State New
Headers show

Comments

Zhiyong Wu - March 26, 2012, 5:40 a.m.
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 net/vde.c |   34 ++++++++++++++++++++++++++++++++--
 net/vde.h |    4 ++--
 2 files changed, 34 insertions(+), 4 deletions(-)

Patch

diff --git a/net/vde.c b/net/vde.c
index 8d9e1c6..c06716d 100644
--- a/net/vde.c
+++ b/net/vde.c
@@ -110,13 +110,17 @@  static int net_vde_init(NetClientState *peer, const char *model,
     return 0;
 }
 
-int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name,
-                 NetClientState *peer)
+int net_init_vde(HOSTDevice *net_dev)
 {
     const char *sock;
     const char *group;
     int port, mode;
 
+    QemuOpts *opts = net_dev->opts;
+    Monitor *mon = net_dev->mon;
+    char *name = g_strdup(net_dev->name);
+    NetClientState *peer = net_dev->peer;
+
     sock  = qemu_opt_get(opts, "sock");
     group = qemu_opt_get(opts, "group");
 
@@ -129,3 +133,29 @@  int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name,
 
     return 0;
 }
+
+static hostdevProperty net_vde_properties[] = {
+    DEFINE_HOSTDEV_PROP_END_OF_LIST(),
+};
+
+static void net_vde_class_init(ObjectClass *klass, void *data)
+{
+    HOSTDeviceClass *k = HOSTDEV_CLASS(klass);
+
+    k->init = net_init_vde;
+    k->props = net_vde_properties;
+}
+
+static TypeInfo net_vde_type = {
+    .name          = "vde",
+    .parent        = TYPE_HOSTDEV,
+    .instance_size = sizeof(NetClientState),
+    .class_init    = net_vde_class_init,
+};
+
+static void net_vde_register_types(void)
+{
+    type_register_static(&net_user_type);
+}
+
+type_init(net_vde_register_types)
diff --git a/net/vde.h b/net/vde.h
index 276e1ff..c99a3a9 100644
--- a/net/vde.h
+++ b/net/vde.h
@@ -26,11 +26,11 @@ 
 
 #include "qemu-common.h"
 #include "qemu-option.h"
+#include "qemu/hostdev.h"
 
 #ifdef CONFIG_VDE
 
-int net_init_vde(QemuOpts *opts, Monitor *mon, const char *name,
-                 NetClientState *peer);
+int net_init_vde(NETDevice *net_dev);
 
 #endif /* CONFIG_VDE */