]> Git Repo - qemu.git/commitdiff
virtio-balloon: fix stats vq migration
authorLadi Prosek <[email protected]>
Wed, 7 Sep 2016 15:20:49 +0000 (17:20 +0200)
committerMichael S. Tsirkin <[email protected]>
Fri, 9 Sep 2016 17:58:34 +0000 (20:58 +0300)
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 <[email protected]>
Cc: Roman Kagan <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Suggested-by: Roman Kagan <[email protected]>
Signed-off-by: Ladi Prosek <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
hw/virtio/virtio-balloon.c

index ad4189a862ceb150b64273528644bbba5d65e076..49a2f4aade16988322cfecd76aa942fd50fc7a86 100644 (file)
@@ -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 = {
This page took 0.030197 seconds and 4 git commands to generate.