From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 0.15 1/4] add support for machine models to specify their migration format
Date: Fri, 29 Jul 2011 17:33:02 +0200 [thread overview]
Message-ID: <1311953585-16021-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1311953585-16021-1-git-send-email-pbonzini@redhat.com>
We need to provide a new migration format, and not break migration
in old machine models. So add a migration_format field to QEMUMachine.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
cpu-common.h | 3 ---
hw/boards.h | 1 +
qemu-common.h | 3 +++
savevm.c | 16 ++++++++++++++--
4 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/cpu-common.h b/cpu-common.h
index 44b04b3..8c61b18 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -26,9 +26,6 @@ enum device_endian {
DEVICE_LITTLE_ENDIAN,
};
-/* address in the RAM (different from a physical address) */
-typedef unsigned long ram_addr_t;
-
/* memory API */
typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
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/qemu-common.h b/qemu-common.h
index ba55719..24330be 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -91,6 +91,9 @@ static inline char *realpath(const char *path, char *resolved_path)
}
#endif
+/* address in the RAM (different from a physical address) */
+typedef unsigned long ram_addr_t;
+
/* FIXME: Remove NEED_CPU_H. */
#ifndef NEED_CPU_H
diff --git a/savevm.c b/savevm.c
index 8139bc7..3049aa1 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"
@@ -1461,6 +1462,16 @@ bool qemu_savevm_state_blocked(Monitor *mon)
return false;
}
+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 qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
int shared)
{
@@ -1474,7 +1484,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;
@@ -1747,8 +1757,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
next prev parent reply other threads:[~2011-07-29 15:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-29 15:33 [Qemu-devel] [PATCH v2 0.15 0/4] Fix subsection ambiguity in the migration format Paolo Bonzini
2011-07-29 15:33 ` Paolo Bonzini [this message]
2011-07-29 15:33 ` [Qemu-devel] [PATCH v2 0.15 2/4] add pc-0.14 machine Paolo Bonzini
2011-07-29 15:33 ` [Qemu-devel] [PATCH v2 0.15 3/4] savevm: define new unambiguous migration format Paolo Bonzini
2011-07-29 15:33 ` [Qemu-devel] [PATCH v2 0.15 4/4] Partially revert "savevm: fix corruption in vmstate_subsection_load()." Paolo Bonzini
2011-08-02 23:06 ` [Qemu-devel] [PATCH v2 0.15 0/4] Fix subsection ambiguity in the migration format Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311953585-16021-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).