qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Juan Quintela <quintela@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Liran Schour <LIRANS@il.ibm.com>,
	Pierre Riteau <Pierre.Riteau@irisa.fr>
Subject: Re: [Qemu-devel] [PATCH] vmstate: Avoid seeking
Date: Tue, 1 Dec 2009 21:24:04 -0600	[thread overview]
Message-ID: <20091202032404.GV32229@us.ibm.com> (raw)
In-Reply-To: <4B15A8FA.5080804@web.de>

* Jan Kiszka <jan.kiszka@web.de> [2009-12-01 17:44]:
> Seeking on vmstate save/load does not work if the underlying file is a
> stream. We could try to make all QEMUFile* forward-seek-aware, but first
> attempts in this direction indicated that it's saner to convert the few
> qemu_fseek-on-vmstates users to plain reads/writes.
> 
> This fixes various subtle vmstate corruptions where unused fields were
> involved.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

With this patch and the VMSTATE_MACADDR patch, localhost migration with
e1000 is working again.

Acked-by: Ryan Harper <ryanh@us.ibm.com>


> ---
> 
>  hw/virtio-net.c |    7 ++-----
>  savevm.c        |   18 ++++++++++++++++--
>  2 files changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 2f147e5..9ccd4c8 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -745,12 +745,9 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
>  
>      if (version_id >= 5) {
>          n->mac_table.in_use = qemu_get_be32(f);
> +        qemu_get_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);
>          /* MAC_TABLE_ENTRIES may be different from the saved image */
> -        if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {
> -            qemu_get_buffer(f, n->mac_table.macs,
> -                            n->mac_table.in_use * ETH_ALEN);
> -        } else if (n->mac_table.in_use) {
> -            qemu_fseek(f, n->mac_table.in_use * ETH_ALEN, SEEK_CUR);
> +        if (n->mac_table.in_use > MAC_TABLE_ENTRIES) {
>              n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
>              n->mac_table.in_use = 0;
>          }
> diff --git a/savevm.c b/savevm.c
> index 8fe9349..1e54a42 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -959,13 +959,27 @@ const VMStateInfo vmstate_info_buffer = {
>  
>  static int get_unused_buffer(QEMUFile *f, void *pv, size_t size)
>  {
> -    qemu_fseek(f, size, SEEK_CUR);
> +    uint8_t buf[1024];
> +    int block_len;
> +
> +    while (size > 0) {
> +        block_len = MIN(sizeof(buf), size);
> +        size -= block_len;
> +        qemu_get_buffer(f, buf, block_len);
> +    }
>      return 0;
>  }
>  
>  static void put_unused_buffer(QEMUFile *f, void *pv, size_t size)
>  {
> -    qemu_fseek(f, size, SEEK_CUR);
> +    static const uint8_t buf[1024];
> +    int block_len;
> +
> +    while (size > 0) {
> +        block_len = MIN(sizeof(buf), size);
> +        size -= block_len;
> +        qemu_put_buffer(f, buf, block_len);
> +    }
>  }
>  
>  const VMStateInfo vmstate_info_unused_buffer = {
> 



-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com

  reply	other threads:[~2009-12-02  3:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-01 23:38 [Qemu-devel] [PATCH] vmstate: Avoid seeking Jan Kiszka
2009-12-02  3:24 ` Ryan Harper [this message]
2009-12-02 10:05 ` [Qemu-devel] " Juan Quintela
2009-12-02 11:14   ` Jan Kiszka
2009-12-02 11:24     ` Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091202032404.GV32229@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=LIRANS@il.ibm.com \
    --cc=Pierre.Riteau@irisa.fr \
    --cc=aliguori@us.ibm.com \
    --cc=jan.kiszka@web.de \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).