All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
	gaudenz@debian.org
Subject: Re: [Qemu-devel] [PATCH for-2.7 1/4] virtio: recalculate vq->inuse after migration
Date: Sat, 13 Aug 2016 00:30:32 +0300	[thread overview]
Message-ID: <20160813003026-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1471015978-1123-2-git-send-email-stefanha@redhat.com>

On Fri, Aug 12, 2016 at 04:32:55PM +0100, Stefan Hajnoczi wrote:
> The vq->inuse field is not migrated.  Many devices don't hold
> VirtQueueElements across migration so it doesn't matter that vq->inuse
> starts at 0 on the destination QEMU.
> 
> At least virtio-serial, virtio-blk, and virtio-balloon migrate while
> holding VirtQueueElements.  For these devices we need to recalculate
> vq->inuse upon load so the value is correct.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>


Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/virtio/virtio.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 15ee3a7..4df8274 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -1648,6 +1648,20 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
>              }
>              vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]);
>              vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]);
> +
> +            /* Some devices migrate VirtQueueElements that have been popped
> +             * from the avail ring but not yet returned to the used ring.
> +             */
> +            vdev->vq[i].inuse = vdev->vq[i].last_avail_idx -
> +                                vdev->vq[i].used_idx;
> +            if (vdev->vq[i].inuse > vdev->vq[i].vring.num) {
> +                error_report("VQ %d size 0x%x < last_avail_idx 0x%x - "
> +                             "used_idx 0x%x"
> +                             i, vdev->vq[i].vring.num,
> +                             vdev->vq[i].last_avail_idx,
> +                             vdev->vq[i].used_idx);
> +                return -1;
> +            }
>          }
>      }
>  
> -- 
> 2.7.4

  reply	other threads:[~2016-08-12 21:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12 15:32 [Qemu-devel] [PATCH for-2.7 0/4] virtio-balloon: fix stats vq migration Stefan Hajnoczi
2016-08-12 15:32 ` [Qemu-devel] [PATCH for-2.7 1/4] virtio: recalculate vq->inuse after migration Stefan Hajnoczi
2016-08-12 21:30   ` Michael S. Tsirkin [this message]
2016-08-14 11:12   ` Fam Zheng
2016-08-15  8:23   ` Cornelia Huck
2016-08-12 15:32 ` [Qemu-devel] [PATCH for-2.7 2/4] virtio: decrement vq->inuse in virtqueue_discard() Stefan Hajnoczi
2016-08-12 21:31   ` Michael S. Tsirkin
2016-08-15  8:24   ` Cornelia Huck
2016-08-12 15:32 ` [Qemu-devel] [PATCH for-2.7 3/4] virtio: add virtqueue_rewind() Stefan Hajnoczi
2016-08-15  8:36   ` Cornelia Huck
2016-08-15 12:34     ` Stefan Hajnoczi
2016-08-12 15:32 ` [Qemu-devel] [PATCH for-2.7 4/4] virtio-balloon: fix stats vq migration Stefan Hajnoczi
2016-08-12 19:43 ` [Qemu-devel] [PATCH for-2.7 0/4] " no-reply
2016-08-15 19:51 ` Gaudenz Steinlin
2016-08-15 21:26   ` Michael S. Tsirkin

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=20160813003026-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=gaudenz@debian.org \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.