summaryrefslogtreecommitdiff
path: root/hw/virtio/virtio-balloon.c
diff options
context:
space:
mode:
authorLadi Prosek <lprosek@redhat.com>2016-09-07 17:20:49 +0200
committerMichael S. Tsirkin <mst@redhat.com>2016-09-09 20:58:34 +0300
commit4a1e48becab81020adfb74b22c76a595f2d02a01 (patch)
tree42a01a634854359dd13197a8717036c4201cc111 /hw/virtio/virtio-balloon.c
parent297a75e6c55d91db2704a3d6e4029d99c7df51fd (diff)
downloadqemu-4a1e48becab81020adfb74b22c76a595f2d02a01.tar.gz
qemu-4a1e48becab81020adfb74b22c76a595f2d02a01.tar.bz2
qemu-4a1e48becab81020adfb74b22c76a595f2d02a01.zip
virtio-balloon: fix stats vq migration
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>
Diffstat (limited to 'hw/virtio/virtio-balloon.c')
-rw-r--r--hw/virtio/virtio-balloon.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index ad4189a862..49a2f4aade 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 = {