All of lore.kernel.org
 help / color / mirror / Atom feed
From: zwu.kernel@gmail.com
To: qemu-devel@nongnu.org
Cc: zwu.kernel@gmail.com, pbonzini@redhat.com,
	Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>,
	stefanha@linux.vnet.ibm.com
Subject: [Qemu-devel] [RFC 9/9] net: qomify -netdev tap & -netdev bridge
Date: Mon, 26 Mar 2012 13:40:23 +0800	[thread overview]
Message-ID: <1332740423-8426-12-git-send-email-zwu.kernel@gmail.com> (raw)
In-Reply-To: <1332740423-8426-1-git-send-email-zwu.kernel@gmail.com>

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

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

diff --git a/net/tap.c b/net/tap.c
index 65f45b8..81d022b 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -512,12 +512,16 @@ static int net_bridge_run_helper(const char *helper, const char *bridge)
     return -1;
 }
 
-int net_init_bridge(QemuOpts *opts, Monitor *mon, const char *name,
-                    NetClientState *peer)
+int net_init_bridge(NETDevice *net_dev)
 {
     TAPState *s;
     int fd, vnet_hdr;
 
+    QemuOpts *opts = net_dev->opts;
+    //Monitor *mon = net_dev->mon;
+    char *name = g_strdup(net_dev->name);
+    NetClientState *peer = net_dev->peer;
+
     if (!qemu_opt_get(opts, "br")) {
         qemu_opt_set(opts, "br", DEFAULT_BRIDGE_INTERFACE);
     }
@@ -583,13 +587,17 @@ static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
     return fd;
 }
 
-int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name,
-                 NetClientState *peer)
+int net_init_tap(NETDevice *net_dev)
 {
     TAPState *s;
     int fd, vnet_hdr = 0;
     const char *model;
 
+    QemuOpts *opts = net_dev->opts;
+    Monitor *mon = net_dev->mon;
+    char *name = g_strdup(net_dev->name);
+    NetClientState *peer = net_dev->peer;
+
     if (qemu_opt_get(opts, "fd")) {
         if (qemu_opt_get(opts, "ifname") ||
             qemu_opt_get(opts, "script") ||
@@ -715,3 +723,51 @@ VHostNetState *tap_get_vhost_net(NetClientState *nc)
     assert(nc->info->type == NET_CLIENT_TYPE_TAP);
     return s->vhost_net;
 }
+
+static hostdevProperty net_tap_properties[] = {
+    DEFINE_HOSTDEV_PROP_END_OF_LIST(),
+};
+
+static void net_tap_class_init(ObjectClass *klass, void *data)
+{
+    NETDeviceClass *k = NETDEV_CLASS(klass);
+    HOSTDeviceClass *dc = HOSTDEV_CLASS(klass);
+
+    k->init = net_init_tap;
+    dc->props = net_tap_properties;
+}
+
+static TypeInfo net_tap_type = {
+    .name          = "tap",
+    .parent        = TYPE_NETDEV,
+    .instance_size = sizeof(NetClientState),
+    .class_init    = net_tap_class_init,
+};
+
+static hostdevProperty net_bridge_properties[] = {
+    DEFINE_HOSTDEV_PROP_END_OF_LIST(),
+};
+
+static void net_bridge_class_init(ObjectClass *klass, void *data)
+{
+    NETDeviceClass *k = NETDEV_CLASS(klass);
+    HOSTDeviceClass *dc = HOSTDEV_CLASS(klass);
+
+    k->init = net_init_bridge;
+    dc->props = net_bridge_properties;
+}
+
+static TypeInfo net_bridge_type = {
+    .name          = "bridge",
+    .parent        = TYPE_NETDEV,
+    .instance_size = sizeof(NetClientState),
+    .class_init    = net_bridge_class_init,
+};
+
+static void net_tap_register_types(void)
+{
+    type_register_static(&net_tap_type);
+    type_register_static(&net_bridge_type);
+}
+
+type_init(net_tap_register_types)
diff --git a/net/tap.h b/net/tap.h
index 0e35e81..5344d24 100644
--- a/net/tap.h
+++ b/net/tap.h
@@ -28,12 +28,13 @@
 
 #include "qemu-common.h"
 #include "qemu-option.h"
+#include "qemu/hostdev.h"
+#include "net.h"
 
 #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
 #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
 
-int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name,
-                 NetClientState *peer);
+int net_init_tap(NETDevice *net_dev);
 
 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required);
 
@@ -58,7 +59,6 @@ int tap_get_fd(NetClientState *nc);
 struct vhost_net;
 struct vhost_net *tap_get_vhost_net(NetClientState *nc);
 
-int net_init_bridge(QemuOpts *opts, Monitor *mon, const char *name,
-                    NetClientState *peer);
+int net_init_bridge(NETDevice *net_dev);
 
 #endif /* QEMU_NET_TAP_H */
-- 
1.7.6

  parent reply	other threads:[~2012-03-26  5:41 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26  5:40 [Qemu-devel] [RFC 0/9] QOM: qomify -netdev zwu.kernel
2012-03-26  5:40 ` [Qemu-devel] [RFC 1/9] hostdev: introduce the infrastructure for host device model zwu.kernel
2012-03-26  5:54   ` Zhi Yong Wu
2012-03-27  8:23   ` Paolo Bonzini
2012-03-27  9:06     ` Zhi Yong Wu
2012-03-27 10:15       ` Paolo Bonzini
2012-03-27 11:59         ` Zhi Yong Wu
2012-03-27 13:58           ` Paolo Bonzini
2012-03-27 14:18             ` Zhi Yong Wu
2012-03-27 14:50               ` Paolo Bonzini
2012-03-27 21:21                 ` Zhi Yong Wu
2012-03-28  6:41                   ` Paolo Bonzini
2012-03-28  7:50                     ` Zhi Yong Wu
2012-03-28  7:53                     ` Zhi Yong Wu
2012-03-28  8:02                       ` Paolo Bonzini
2012-03-28  8:05                         ` 陳韋任
2012-03-28  8:25                           ` Zhi Yong Wu
2012-03-28  8:29                             ` 陳韋任
2012-03-26  5:40 ` [Qemu-devel] [PATCH] net: qomify -netdev zwu.kernel
2012-03-26  5:40 ` zwu.kernel
2012-03-26  5:44   ` Zhi Yong Wu
2012-03-26  5:40 ` [Qemu-devel] [RFC 2/9] net: introduce one net host device class zwu.kernel
2012-03-27  8:30   ` Paolo Bonzini
2012-03-27  9:13     ` Zhi Yong Wu
2012-03-26  5:40 ` [Qemu-devel] [RFC 3/9] net: adjust net common part for qomify -netdev zwu.kernel
2012-03-26  5:40 ` [Qemu-devel] [RFC 4/9] net: adjust nic init API zwu.kernel
2012-03-26  5:40 ` [Qemu-devel] [RFC 5/9] net: adjust dump " zwu.kernel
2012-03-26  5:40 ` [Qemu-devel] [RFC 6/9] net: qomify -netdev user zwu.kernel
2012-03-26  5:40 ` [Qemu-devel] [RFC 7/9] net: qomify -netdev socket zwu.kernel
2012-03-26  5:40 ` [Qemu-devel] [RFC 8/9] net: qomify -netdev vde zwu.kernel
2012-03-26  5:40 ` zwu.kernel [this message]
2012-03-26 11:54 ` [Qemu-devel] [RFC 0/9] QOM: qomify -netdev Stefan Hajnoczi
2012-03-26 14:20   ` Zhi Yong Wu
2012-03-27  8:19     ` Paolo Bonzini
2012-03-27  9:03       ` Zhi Yong Wu
2012-03-26 14:39   ` Andreas Färber
2012-03-26 14:57     ` Stefan Hajnoczi
2012-03-26 15:01     ` Zhi Yong Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332740423-8426-12-git-send-email-zwu.kernel@gmail.com \
    --to=zwu.kernel@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=wuzhy@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.