qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 1/4] add support for machine models to specify th


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH v3 1/4] add support for machine models to specify their migration format
Date: Fri, 12 Aug 2011 11:59:38 +0200

We need to provide a new migration format, and not break migration
in old machine models.  So add a migration_format field to QEMUMachine.

This adds a dependency on ram_addr_t to savevm.c (through hw/boards.h),
whose type definition depends on the word size.  So move savevm.o to
libhw.

Signed-off-by: Paolo Bonzini <address@hidden>
---
 Makefile.objs |    4 ++--
 hw/boards.h   |    1 +
 savevm.c      |   16 ++++++++++++++--
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index 89ca361..039d1fd 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -108,7 +108,7 @@ common-obj-$(CONFIG_SD) += sd.o
 common-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o 
usb-bt.o
 common-obj-y += bt-hci-csr.o
 common-obj-y += buffered_file.o migration.o migration-tcp.o
-common-obj-y += qemu-char.o savevm.o #aio.o
+common-obj-y += qemu-char.o #aio.o
 common-obj-y += msmouse.o ps2.o
 common-obj-y += qdev.o qdev-properties.o
 common-obj-y += block-migration.o iohandler.o
@@ -181,7 +181,7 @@ user-obj-y += cutils.o cache-utils.o
 # libhw
 
 hw-obj-y =
-hw-obj-y += vl.o loader.o
+hw-obj-y += vl.o loader.o savevm.o
 hw-obj-$(CONFIG_VIRTIO) += virtio-console.o
 hw-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 hw-obj-y += fw_cfg.o
diff --git a/hw/boards.h b/hw/boards.h
index 716fd7b..560dbaf 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -19,6 +19,7 @@ typedef struct QEMUMachine {
     QEMUMachineInitFunc *init;
     int use_scsi;
     int max_cpus;
+    unsigned migration_format;
     unsigned int no_serial:1,
         no_parallel:1,
         use_virtcon:1,
diff --git a/savevm.c b/savevm.c
index 9f4a3af..87f2b71 100644
--- a/savevm.c
+++ b/savevm.c
@@ -72,6 +72,7 @@
 #include "qemu-common.h"
 #include "hw/hw.h"
 #include "hw/qdev.h"
+#include "hw/boards.h"
 #include "net.h"
 #include "monitor.h"
 #include "sysemu.h"
@@ -1215,6 +1216,15 @@ void register_device_unmigratable(DeviceState *dev, 
const char *idstr,
     }
 }
 
+static inline int qemu_current_migration_format(void)
+{
+    if (current_machine->migration_format)
+        return current_machine->migration_format;
+
+    /* No format specified, default to the latest.  */
+    return QEMU_VM_FILE_VERSION;
+}
+
 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *opaque, int alias_id,
@@ -1484,7 +1494,7 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, 
int blk_enable,
     }
     
     qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
-    qemu_put_be32(f, QEMU_VM_FILE_VERSION);
+    qemu_put_be32(f, qemu_current_migration_format());
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {
         int len;
@@ -1761,8 +1771,10 @@ int qemu_loadvm_state(QEMUFile *f)
         fprintf(stderr, "SaveVM v2 format is obsolete and don't work 
anymore\n");
         return -ENOTSUP;
     }
-    if (v != QEMU_VM_FILE_VERSION)
+    if (v != qemu_current_migration_format()) {
+        fprintf(stderr, "Mismatching SaveVM format v%d\n", v);
         return -ENOTSUP;
+    }
 
     while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
         uint32_t instance_id, version_id, section_id;
-- 
1.7.6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]