From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFqZt-0001CN-Us for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:53:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFqZo-0001Aw-7O for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:53:12 -0500 Received: from [199.232.76.173] (port=51968 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFqZn-0001Aa-8E for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:53:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7264) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFqZm-0001mY-7I for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:53:06 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB2Er5Ui023054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Dec 2009 09:53:05 -0500 Date: Wed, 2 Dec 2009 16:50:27 +0200 From: "Michael S. Tsirkin" Message-ID: <20091202145026.GE18519@redhat.com> References: <10b06036c31c476dfd823e086cb4aa253cd93a7f.1259754427.git.quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10b06036c31c476dfd823e086cb4aa253cd93a7f.1259754427.git.quintela@redhat.com> Subject: [Qemu-devel] Re: [PATCH 28/41] virtio-net: make vlan operations on uint8_t, not uint32_t List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org On Wed, Dec 02, 2009 at 01:04:26PM +0100, Juan Quintela wrote: > This fixes endianess problems. Using ints and saving the state as bytes > break cross-endian migration. > > Signed-off-by: Juan Quintela Good catch in itself, but relies on a broken patch before that. > --- > hw/virtio-net.c | 12 ++++++------ > 1 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/hw/virtio-net.c b/hw/virtio-net.c > index cf13e94..05cc67f 100644 > --- a/hw/virtio-net.c > +++ b/hw/virtio-net.c > @@ -56,7 +56,7 @@ typedef struct VirtIONet > uint8_t uni_overflow; > uint8_t *macs; > } mac_table; > - uint32_t vlans[MAX_VLAN >> 5]; > + uint8_t vlans[MAX_VLAN >> 3]; > } VirtIONet; > > /* TODO > @@ -65,17 +65,17 @@ typedef struct VirtIONet > > static void vlan_add(VirtIONet *n, int vid) > { > - n->vlans[vid >> 5] |= (1U << (vid & 0x1f)); > + n->vlans[vid >> 3] |= (1U << (vid & 0x7)); > } > > static void vlan_del(VirtIONet *n, int vid) > { > - n->vlans[vid >> 5] &= ~(1U << (vid & 0x1f)); > + n->vlans[vid >> 3] &= ~(1U << (vid & 0x7)); > } > > static bool vlan_is_set(VirtIONet *n, int vid) > { > - return n->vlans[vid >> 5] & ~(1U << (vid & 0x1f)); > + return n->vlans[vid >> 3] & ~(1U << (vid & 0x7)); > } > > static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) > @@ -717,7 +717,7 @@ static void virtio_net_save(QEMUFile *f, void *opaque) > qemu_put_8s(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); > + qemu_put_buffer(f, n->vlans, MAX_VLAN >> 3); > qemu_put_be32(f, n->has_vnet_hdr); > qemu_put_8s(f, &n->mac_table.multi_overflow); > qemu_put_8s(f, &n->mac_table.uni_overflow); > @@ -762,7 +762,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) > } > > if (version_id >= 6) > - qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3); > + qemu_get_buffer(f, n->vlans, MAX_VLAN >> 3); > > if (version_id >= 7) { > if (qemu_get_be32(f) && !peer_has_vnet_hdr(n)) { > -- > 1.6.5.2