[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/37] virtio: add subsections to the migration strea
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 23/37] virtio: add subsections to the migration stream |
Date: |
Sun, 29 Jun 2014 19:59:24 +0300 |
From: Greg Kurz <address@hidden>
There is a need to add some more fields to VirtIODevice that should be
migrated (broken status, endianness). The problem is that we do not
want to break compatibility while adding a new feature... This issue has
been addressed in the generic VMState code with the use of optional
subsections. As a *temporary* alternative to port the whole virtio
migration code to VMState, this patch mimics a similar subsectionning
ability for virtio, using the VMState code.
Since each virtio device is streamed in its own section, the idea is to
stream subsections between the end of the device section and the start
of the next sections. This allows an older QEMU to complain and exit
when fed with subsections:
Unknown savevm section type 5
load of migration failed
Suggested-by: Alexander Graf <address@hidden>
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Alexander Graf <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 7f9ac5e..7b317ce 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -19,6 +19,7 @@
#include "hw/virtio/virtio.h"
#include "qemu/atomic.h"
#include "hw/virtio/virtio-bus.h"
+#include "migration/migration.h"
/*
* The alignment to use between consumer and producer parts of vring.
@@ -839,6 +840,16 @@ void virtio_notify_config(VirtIODevice *vdev)
virtio_notify_vector(vdev, vdev->config_vector);
}
+static const VMStateDescription vmstate_virtio = {
+ .name = "virtio",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_END_OF_LIST()
+ }
+};
+
void virtio_save(VirtIODevice *vdev, QEMUFile *f)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
@@ -882,6 +893,9 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
if (vdc->save != NULL) {
vdc->save(vdev, f);
}
+
+ /* Subsections */
+ vmstate_save_state(f, &vmstate_virtio, vdev);
}
int virtio_set_features(VirtIODevice *vdev, uint32_t val)
@@ -991,10 +1005,13 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int
version_id)
virtio_notify_vector(vdev, VIRTIO_NO_VECTOR);
if (vdc->load != NULL) {
- return vdc->load(vdev, f, version_id);
+ ret = vdc->load(vdev, f, version_id);
+ if (ret) {
+ return ret;
+ }
}
- return 0;
+ return vmstate_load_state(f, &vmstate_virtio, vdev, 1);
}
void virtio_cleanup(VirtIODevice *vdev)
--
MST
- [Qemu-devel] [PULL 13/37] vhost-user: fix regions provied with VHOST_USER_SET_MEM_TABLE message, (continued)
- [Qemu-devel] [PULL 13/37] vhost-user: fix regions provied with VHOST_USER_SET_MEM_TABLE message, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 14/37] vhost-user: typo fixups, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 15/37] virtio-net: byteswap virtio-net header, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 17/37] virtio: introduce device specific migration calls, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 16/37] virtio-serial: don't migrate the config space, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 18/37] virtio-net: implement per-device migration calls, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 19/37] virtio-blk: implement per-device migration calls, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 20/37] virtio-serial: implement per-device migration calls, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 21/37] virtio-balloon: implement per-device migration calls, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 22/37] virtio-rng: implement per-device migration calls, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 23/37] virtio: add subsections to the migration stream,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 24/37] exec: introduce target_words_bigendian() helper, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 25/37] cpu: introduce CPUClass::virtio_is_big_endian(), Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 26/37] virtio: add endian-ambivalent support to VirtIODevice, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 27/37] virtio: memory accessors for endian-ambivalent targets, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 28/37] virtio: allow byte swapping for vring, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 29/37] virtio-net: use virtio wrappers to access headers, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 30/37] virtio-balloon: use virtio wrappers to access page frame numbers, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 31/37] virtio-blk: use virtio wrappers to access headers, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 32/37] virtio-scsi: use virtio wrappers to access headers, Michael S. Tsirkin, 2014/06/29
- [Qemu-devel] [PULL 33/37] virtio-serial-bus: use virtio wrappers to access headers, Michael S. Tsirkin, 2014/06/29