qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits
Date: Wed, 21 Oct 2009 15:25:26 +0200

Add a new type for properties common to all nics.
Add helper functions and macros to deal with it.

Signed-off-by: Gerd Hoffmann <address@hidden>
---
 hw/qdev.c |    9 +++++++++
 net.h     |   14 ++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 20f931c..b32dbfc 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -383,6 +383,15 @@ void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr)
     memcpy(macaddr, dev->nd->macaddr, 6);
 }
 
+void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
+{
+    qdev_prop_set_macaddr(dev, "mac", nd->macaddr);
+    if (nd->vlan)
+        qdev_prop_set_vlan(dev, "vlan", nd->vlan);
+    if (nd->netdev)
+        qdev_prop_set_netdev(dev, "netdev", nd->netdev);
+}
+
 static int next_block_unit[IF_COUNT];
 
 /* Get a block device.  This should only be used for single-drive devices
diff --git a/net.h b/net.h
index 6a24f55..f2d10f0 100644
--- a/net.h
+++ b/net.h
@@ -11,6 +11,19 @@ struct MACAddr {
     uint8_t a[6];
 };
 
+/* qdev nic properties */
+
+typedef struct NICConf {
+    MACAddr macaddr;
+    VLANState *vlan;
+    VLANClientState *peer;
+} NICConf;
+
+#define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
+    DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr),                \
+    DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan),                   \
+    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer)
+
 /* VLANs support */
 
 typedef int (NetCanReceive)(VLANClientState *);
@@ -158,5 +171,6 @@ VLANClientState *qdev_get_vlan_client(DeviceState *dev,
                                       NetReceiveIOV *receive_iov,
                                       NetCleanup *cleanup,
                                       void *opaque);
+void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
 
 #endif
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]