From patchwork Tue Feb 3 19:29:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 5290 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n13JWfJw031933 for ; Tue, 3 Feb 2009 19:32:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752326AbZBCTck (ORCPT ); Tue, 3 Feb 2009 14:32:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752372AbZBCTck (ORCPT ); Tue, 3 Feb 2009 14:32:40 -0500 Received: from g1t0029.austin.hp.com ([15.216.28.36]:33295 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752326AbZBCTcj (ORCPT ); Tue, 3 Feb 2009 14:32:39 -0500 Received: from g4t0018.houston.hp.com (g4t0018.houston.hp.com [16.234.32.27]) by g1t0029.austin.hp.com (Postfix) with ESMTP id E2909381D0; Tue, 3 Feb 2009 19:32:37 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g4t0018.houston.hp.com (Postfix) with ESMTP id AA98410032; Tue, 3 Feb 2009 19:32:37 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 5D7F339C07B; Tue, 3 Feb 2009 12:32:37 -0700 (MST) X-Virus-Scanned: Debian amavisd-new at ldl.fc.hp.com Received: from ldl.fc.hp.com ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2d72BO75nSDs; Tue, 3 Feb 2009 12:32:37 -0700 (MST) Received: from kvm.aw (lart.fc.hp.com [15.11.146.31]) by ldl.fc.hp.com (Postfix) with ESMTP id CD5C339C00D; Tue, 3 Feb 2009 12:32:36 -0700 (MST) From: Alex Williamson Subject: [PATCH v2 3/8] qemu:virtio-net: Define ETH_ALEN for use when manipulating MAC addresses To: anthony@codemonkey.ws, qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, markmc@redhat.com Date: Tue, 03 Feb 2009 12:29:48 -0700 Message-ID: <20090203192948.19598.42228.stgit@kvm.aw> In-Reply-To: <20090203192932.19598.50925.stgit@kvm.aw> References: <20090203192932.19598.50925.stgit@kvm.aw> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Makes it much easier to search too. Signed-off-by: Alex Williamson Acked-by: Mark McLoughlin --- hw/virtio-net.c | 14 +++++++------- hw/virtio-net.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 105daa9..073f23a 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -21,7 +21,7 @@ typedef struct VirtIONet { VirtIODevice vdev; - uint8_t mac[6]; + uint8_t mac[ETH_ALEN]; uint16_t status; VirtQueue *rx_vq; VirtQueue *tx_vq; @@ -46,7 +46,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)); } @@ -57,8 +57,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); } } @@ -304,7 +304,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); qemu_put_be16(f, n->status); @@ -319,7 +319,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); @@ -356,7 +356,7 @@ void 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); diff --git a/hw/virtio-net.h b/hw/virtio-net.h index 148ec47..9dce663 100644 --- a/hw/virtio-net.h +++ b/hw/virtio-net.h @@ -18,6 +18,8 @@ #include "net.h" #include "pci.h" +#define ETH_ALEN 6 + /* from Linux's virtio_net.h */ /* The ID for virtio_net */