[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 33/41] virtio-net: port to vmstate
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] Re: [PATCH 33/41] virtio-net: port to vmstate |
Date: |
Wed, 2 Dec 2009 20:40:01 +0200 |
User-agent: |
Mutt/1.5.19 (2009-01-05) |
On Wed, Dec 02, 2009 at 07:38:03PM +0100, Juan Quintela wrote:
> "Michael S. Tsirkin" <address@hidden> wrote:
> > On Wed, Dec 02, 2009 at 01:04:31PM +0100, Juan Quintela wrote:
> >>
> >> Signed-off-by: Juan Quintela <address@hidden>
> >> ---
> >> 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).
I expect it fits in practice.
But you should range check the value and fail migration on error.
> 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.
vmstate guarantees this won't be called?
So just assert(1)? Let's not write a ton of
code that isn't called?
>
>
> > 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.
[Qemu-devel] Re: [PATCH 33/41] virtio-net: port to vmstate, Michael S. Tsirkin, 2009/12/02
[Qemu-devel] [PATCH 34/41] virtio-console: port to vmstate, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 35/41] virtio-balloon: port to vmstate, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 36/41] virtio-blk: change rq type to VirtIOBlockReq, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 37/41] QLIST: Introduce QLIST_COPY_HEAD, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 38/41] virtio-blk: use QLIST for the list of requests, Juan Quintela, 2009/12/02