From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MCgOx-0001Le-Bc for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MCgOs-0001G8-Mj for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:35 -0400 Received: from [199.232.76.173] (port=38241 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MCgOs-0001Fz-Gs for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:30 -0400 Received: from g4t0014.houston.hp.com ([15.201.24.17]:42900) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MCgOr-0005sE-V1 for qemu-devel@nongnu.org; Fri, 05 Jun 2009 16:52:30 -0400 Received: from g4t0009.houston.hp.com (g4t0009.houston.hp.com [16.234.32.26]) by g4t0014.houston.hp.com (Postfix) with ESMTP id DD38024050 for ; Fri, 5 Jun 2009 20:52:28 +0000 (UTC) From: Alex Williamson Date: Fri, 05 Jun 2009 14:46:57 -0600 Message-ID: <20090605204657.3355.65388.stgit@kvm.aw> In-Reply-To: <20090605204647.3355.81929.stgit@kvm.aw> References: <20090605204647.3355.81929.stgit@kvm.aw> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/7] virtio-net: Use a byte to store RX mode flags List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@hp.com There's no need to save 4 bytes for promisc and allmulti. Use one byte each just to avoid the overhead of a bitmap. Signed-off-by: Alex Williamson --- hw/virtio-net.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 9471d9e..de5a59f 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -16,7 +16,7 @@ #include "qemu-timer.h" #include "virtio-net.h" -#define VIRTIO_NET_VM_VERSION 7 +#define VIRTIO_NET_VM_VERSION 8 #define MAC_TABLE_ENTRIES 32 #define MAX_VLAN (1 << 12) /* Per 802.1Q definition */ @@ -33,8 +33,8 @@ typedef struct VirtIONet QEMUTimer *tx_timer; int tx_timer_active; int mergeable_rx_bufs; - int promisc; - int allmulti; + uint8_t promisc; + uint8_t allmulti; struct { int in_use; uint8_t *macs; @@ -518,8 +518,8 @@ static void virtio_net_save(QEMUFile *f, void *opaque) qemu_put_be32(f, n->tx_timer_active); qemu_put_be32(f, n->mergeable_rx_bufs); qemu_put_be16(f, n->status); - qemu_put_be32(f, n->promisc); - qemu_put_be32(f, n->allmulti); + qemu_put_byte(f, n->promisc); + qemu_put_byte(f, n->allmulti); qemu_put_be32(f, n->mac_table.in_use); qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN); qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3); @@ -543,8 +543,13 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) n->status = qemu_get_be16(f); if (version_id >= 4) { - n->promisc = qemu_get_be32(f); - n->allmulti = qemu_get_be32(f); + if (version_id < 8) { + n->promisc = qemu_get_be32(f); + n->allmulti = qemu_get_be32(f); + } else { + n->promisc = qemu_get_byte(f); + n->allmulti = qemu_get_byte(f); + } } if (version_id >= 5) {