Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFu6E-0002Rr-Lk for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:38:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFu69-0002KZ-NV for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:38:49 -0500 Received: from [199.232.76.173] (port=52299 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFu69-0002KB-Bk for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:38:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57030) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFu68-0006c0-5W for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:38:45 -0500 From: Juan Quintela In-Reply-To: <20091202145853.GH18519@redhat.com> (Michael S. Tsirkin's message of "Wed, 2 Dec 2009 16:58:53 +0200") References: <20091202145853.GH18519@redhat.com> Date: Wed, 02 Dec 2009 19:38:03 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 33/41] virtio-net: port to vmstate List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org "Michael S. Tsirkin" wrote: > On Wed, Dec 02, 2009 at 01:04:31PM +0100, Juan Quintela wrote: >> >> Signed-off-by: Juan Quintela >> --- >> hw/virtio-net.c | 148 ++++++++++++++++++++++++------------------------------- >> 1 files changed, 64 insertions(+), 84 deletions(-) >> >> diff --git a/hw/virtio-net.c b/hw/virtio-net.c >> index 4434827..3a59449 100644 >> --- a/hw/virtio-net.c >> +++ b/hw/virtio-net.c >> @@ -703,6 +703,38 @@ static void virtio_net_tx_timer(void *opaque) >> virtio_net_flush_tx(n, n->tx_vq); >> } >> >> +/* Restore an uint8_t from an uint32_t >> + This is a Big hack, but it is how the old state did it. >> + */ >> + >> +static int get_uint8_from_uint32(QEMUFile *f, void *pv, size_t size) >> +{ >> + uint8_t *v = pv; >> + *v = qemu_get_be32(f); >> + return 0; >> +} >> + >> +static void put_unused(QEMUFile *f, void *pv, size_t size) >> +{ >> + fprintf(stderr, "uint8_from_uint32 is used only for backwards compatibility.\n"); > > line too long > >> + fprintf(stderr, "Never should be used to write a new state.\n"); >> + exit(0); > > I don't understand. what is this dong? it is used later. current code is reading an uint32_t value into a int8_t value. As you can guess that don't fit (that is the HACK part of it). That is only needed for old versions that we are reading (get_* function has real code). But we are supposed to never write old versions (*). Thet that shouldn't happen ever. > when > is this called? Please supply a comment. > Maybe call assert? > assert or exit is ok for me, what does people preffer? Later, Juan. (*): My next series will propose to change that and allow to write old versions, but that didn't exist when this code was written, and there are still no agreement about how/if doing it.