All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Ladi Prosek <lprosek@redhat.com>,
	Roman Kagan <rkagan@virtuozzo.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL v2 09/14] virtio-balloon: fix stats vq migration
Date: Sat, 10 Sep 2016 00:47:33 +0300	[thread overview]
Message-ID: <1473456998-14863-10-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1473456998-14863-1-git-send-email-mst@redhat.com>

From: Ladi Prosek <lprosek@redhat.com>

The statistics virtqueue is not migrated properly because virtio-balloon
does not include s->stats_vq_elem in the migration stream.

After migration the statistics virtqueue hangs because the host never
completes the last element (s->stats_vq_elem is NULL on the destination
QEMU).  Therefore the guest never submits new elements and the virtqueue
is hung.

Instead of changing the migration stream format in an incompatible way,
detect the migration case and rewind the virtqueue so the last element
can be completed.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Roman Kagan <rkagan@virtuozzo.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Suggested-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/virtio-balloon.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index ad4189a..49a2f4a 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -469,6 +469,18 @@ static void virtio_balloon_device_reset(VirtIODevice *vdev)
     }
 }
 
+static void virtio_balloon_set_status(VirtIODevice *vdev, uint8_t status)
+{
+    VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
+
+    if (!s->stats_vq_elem && vdev->vm_running &&
+        (status & VIRTIO_CONFIG_S_DRIVER_OK) && virtqueue_rewind(s->svq, 1)) {
+        /* poll stats queue for the element we have discarded when the VM
+         * was stopped */
+        virtio_balloon_receive_stats(vdev, s->svq);
+    }
+}
+
 static void virtio_balloon_instance_init(Object *obj)
 {
     VirtIOBalloon *s = VIRTIO_BALLOON(obj);
@@ -506,6 +518,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
     vdc->get_features = virtio_balloon_get_features;
     vdc->save = virtio_balloon_save_device;
     vdc->load = virtio_balloon_load_device;
+    vdc->set_status = virtio_balloon_set_status;
 }
 
 static const TypeInfo virtio_balloon_info = {
-- 
MST

  parent reply	other threads:[~2016-09-09 21:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 21:47 [Qemu-devel] [PULL v2 00/14] virtio,vhost,pc: fixes and updates Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 01/14] virtio: Tell the user what went wrong when event_notifier_init failed Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 02/14] virtio-pci: use size from correct structure Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 03/14] pc: Add 2.8 machine Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 04/14] target-i386: present virtual L3 cache info for vcpus Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 05/14] virtio-pci: reduce modern_mem_bar size Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 06/14] virtio: zero vq->inuse in virtio_reset() Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 07/14] virtio-balloon: discard virtqueue element on reset Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 08/14] virtio: add virtqueue_rewind() Michael S. Tsirkin
2016-09-09 21:47 ` Michael S. Tsirkin [this message]
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 10/14] virtio-pci: error out when both legacy and modern modes are disabled Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 11/14] vhost: don't set vring call if no vector Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 12/14] virtio-pci: minor refactoring Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 13/14] tests/acpi: speedup acpi tests Michael S. Tsirkin
2016-09-09 21:47 ` [Qemu-devel] [PULL v2 14/14] vhost-vsock: add virtio sockets device Michael S. Tsirkin
2016-09-12 11:48 ` [Qemu-devel] [PULL v2 00/14] virtio, vhost, pc: fixes and updates Peter Maydell

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=1473456998-14863-10-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=lprosek@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rkagan@virtuozzo.com \
    --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.