qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/7] qemu:virtio-net: Define ETH_ALEN for use when m


From: Alex Williamson
Subject: [Qemu-devel] [PATCH 2/7] qemu:virtio-net: Define ETH_ALEN for use when manipulating MAC addresses
Date: Fri, 16 Jan 2009 14:10:05 -0700
User-agent: StGIT/0.14.2

Makes it much easier to search too.

Signed-off-by: Alex Williamson <address@hidden>
---

 qemu/hw/virtio-net.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c
index 3767ecc..44827bc 100644
--- a/qemu/hw/virtio-net.c
+++ b/qemu/hw/virtio-net.c
@@ -23,10 +23,12 @@
 
 #define VIRTIO_NET_VM_VERSION    3
 
+#define ETH_ALEN    6
+
 typedef struct VirtIONet
 {
     VirtIODevice vdev;
-    uint8_t mac[6];
+    uint8_t mac[ETH_ALEN];
     uint16_t status;
     VirtQueue *rx_vq;
     VirtQueue *tx_vq;
@@ -51,7 +53,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t 
*config)
     struct virtio_net_config netcfg;
 
     netcfg.status = n->status;
-    memcpy(netcfg.mac, n->mac, 6);
+    memcpy(netcfg.mac, n->mac, ETH_ALEN);
     memcpy(config, &netcfg, sizeof(netcfg));
 }
 
@@ -62,8 +64,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const 
uint8_t *config)
 
     memcpy(&netcfg, config, sizeof(netcfg));
 
-    if (memcmp(netcfg.mac, n->mac, 6)) {
-        memcpy(n->mac, netcfg.mac, 6);
+    if (memcmp(netcfg.mac, n->mac, ETH_ALEN)) {
+        memcpy(n->mac, netcfg.mac, ETH_ALEN);
         qemu_format_nic_info_str(n->vc, n->mac);
     }
 }
@@ -394,7 +396,7 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
 
     virtio_save(&n->vdev, f);
 
-    qemu_put_buffer(f, n->mac, 6);
+    qemu_put_buffer(f, n->mac, ETH_ALEN);
     qemu_put_be32(f, n->tx_timer_active);
     qemu_put_be32(f, n->mergeable_rx_bufs);
 
@@ -416,7 +418,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int 
version_id)
 
     virtio_load(&n->vdev, f);
 
-    qemu_get_buffer(f, n->mac, 6);
+    qemu_get_buffer(f, n->mac, ETH_ALEN);
     n->tx_timer_active = qemu_get_be32(f);
     n->mergeable_rx_bufs = qemu_get_be32(f);
 
@@ -456,7 +458,7 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int 
devfn)
     n->vdev.set_features = virtio_net_set_features;
     n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);
     n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
-    memcpy(n->mac, nd->macaddr, 6);
+    memcpy(n->mac, nd->macaddr, ETH_ALEN);
     n->status = VIRTIO_NET_S_LINK_UP;
     n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
                                  virtio_net_receive, virtio_net_can_receive, 
n);





reply via email to

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