]> git.proxmox.com Git - qemu.git/commitdiff
net: introduce NICState and qemu_new_nic()
authorMark McLoughlin <markmc@redhat.com>
Wed, 25 Nov 2009 18:49:10 +0000 (18:49 +0000)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 3 Dec 2009 15:41:30 +0000 (09:41 -0600)
Common state for all NICs.

The opaque member will replace the opaque member in VLANClientState
since only NICs need it.

The conf member will allow us to iterate over NICs, access the MAC
addr for the NIC and send a packet from each NIC in qemu_announce_self().

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
net.c
net.h

diff --git a/net.c b/net.c
index 355eb874a69b1ff32c087577088b8b3e956b498a..7195827cc487f870b9064480ce721e18b98e23da 100644 (file)
--- a/net.c
+++ b/net.c
@@ -293,6 +293,27 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
     return vc;
 }
 
+NICState *qemu_new_nic(NetClientInfo *info,
+                       NICConf *conf,
+                       const char *model,
+                       const char *name,
+                       void *opaque)
+{
+    VLANClientState *nc;
+    NICState *nic;
+
+    assert(info->type == NET_CLIENT_TYPE_NIC);
+    assert(info->size >= sizeof(NICState));
+
+    nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name);
+
+    nic = DO_UPCAST(NICState, nc, nc);
+    nic->conf = conf;
+    nic->opaque = opaque;
+
+    return nic;
+}
+
 VLANClientState *qemu_new_vlan_client(net_client_type type,
                                       VLANState *vlan,
                                       VLANClientState *peer,
diff --git a/net.h b/net.h
index 71a9a443e00fa5240cbd5b1c6d760483a2739fca..4de20de355fe2f5cb9919531a8802921dd97b12c 100644 (file)
--- a/net.h
+++ b/net.h
@@ -75,6 +75,12 @@ struct VLANClientState {
     unsigned receive_disabled : 1;
 };
 
+typedef struct NICState {
+    VLANClientState nc;
+    NICConf *conf;
+    void *opaque;
+} NICState;
+
 struct VLANState {
     int id;
     QTAILQ_HEAD(, VLANClientState) clients;
@@ -90,6 +96,11 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
                                      VLANClientState *peer,
                                      const char *model,
                                      const char *name);
+NICState *qemu_new_nic(NetClientInfo *info,
+                       NICConf *conf,
+                       const char *model,
+                       const char *name,
+                       void *opaque);
 VLANClientState *qemu_new_vlan_client(net_client_type type,
                                       VLANState *vlan,
                                       VLANClientState *peer,