@@ -566,8 +566,17 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
VirtIOBlock *s = opaque;
int ret;
- if (version_id != 2)
+#ifdef HOST_WORDS_BIGENDIAN
+ /* Because of the use of native endianness, we can't reliably handle
+ * migration below this version on big endian hosts. */
+ if (version < 3) {
return -EINVAL;
+ }
+#endif
+
+ if (version_id < 2) {
+ return -EINVAL;
+ }
ret = virtio_load(&s->vdev, f);
if (ret) {
@@ -633,7 +642,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk)
qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
s->qdev = dev;
- register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
+ register_savevm(dev, "virtio-blk", virtio_blk_id++, 3,
virtio_blk_save, virtio_blk_load, s);
bdrv_set_dev_ops(s->bs, &virtio_block_ops, s);
bdrv_set_buffer_alignment(s->bs, s->conf->logical_block_size);
@@ -665,9 +665,14 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
unsigned int i;
int ret;
- if (version_id > 3) {
+#ifdef HOST_WORDS_BIGENDIAN
+ /* Because of the use of native endianness, we can't reliably handle
+ * migration below this version on big endian hosts. */
+
+ if (version_id < 4) {
return -EINVAL;
}
+#endif
/* The virtio device */
ret = virtio_load(&s->vdev, f);
@@ -987,7 +992,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
* Register for the savevm section with the virtio-console name
* to preserve backward compat
*/
- register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save,
+ register_savevm(dev, "virtio-console", -1, 4, virtio_serial_save,
virtio_serial_load, vser);
vser->post_load.timer = qemu_new_timer_ns(vm_clock,
And disable migration on big endian hosts from older versions where endianness of the device state was ambiguous on the wire. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- hw/virtio-blk.c | 13 +++++++++++-- hw/virtio-serial-bus.c | 9 +++++++-- 2 files changed, 18 insertions(+), 4 deletions(-)