summaryrefslogtreecommitdiffstats
path: root/migration/savevm.c
diff options
context:
space:
mode:
authorPeter Maydell2019-05-16 11:24:08 +0200
committerPeter Maydell2019-05-16 11:24:08 +0200
commitc1497fba36465d0259d4d04f2bf09ea59ed42680 (patch)
tree80b616d06242e232762600f80b2d7745ea5015e2 /migration/savevm.c
parentMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190513' into staging (diff)
parentmonitor: Call mon_get_cpu() only once at hmp_gva2gpa() (diff)
downloadqemu-c1497fba36465d0259d4d04f2bf09ea59ed42680.tar.gz
qemu-c1497fba36465d0259d4d04f2bf09ea59ed42680.tar.xz
qemu-c1497fba36465d0259d4d04f2bf09ea59ed42680.zip
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190514b' into staging
Migration pull 2019-05-14 Small fixes/cleanups One HMP/monitor fix # gpg: Signature made Tue 14 May 2019 19:03:53 BST # gpg: using RSA key 45F5C71B4A0CB7FB977A9FA90516331EBC5BFDE7 # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" [full] # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7 * remotes/dgilbert/tags/pull-migration-20190514b: monitor: Call mon_get_cpu() only once at hmp_gva2gpa() migration/ram.c: fix typos in comments migration: Fix use-after-free during process exit migration/savevm: wrap into qemu_loadvm_state_header() migration/savevm: load_header before load_setup migration/savevm: remove duplicate check of migration_is_blocked migration: update comments of migration bitmap migration/ram.c: start of migration_bitmap_sync_range is always 0 qemu-option.hx: Update missed parameter for colo-compare migration/colo.h: Remove obsolete codes migration/colo.c: Remove redundant input parameter migration: savevm: fix error code with migration blockers vmstate: check subsection_found is enough migration: remove not used field xfer_limit migration: not necessary to check ops again migration: comment VMSTATE_UNUSED*() properly Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'migration/savevm.c')
-rw-r--r--migration/savevm.c89
1 files changed, 47 insertions, 42 deletions
diff --git a/migration/savevm.c b/migration/savevm.c
index 34bcad3807..c0e557b4c2 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1157,15 +1157,13 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy)
if (!se->ops || !se->ops->save_live_iterate) {
continue;
}
- if (se->ops && se->ops->is_active) {
- if (!se->ops->is_active(se->opaque)) {
- continue;
- }
+ if (se->ops->is_active &&
+ !se->ops->is_active(se->opaque)) {
+ continue;
}
- if (se->ops && se->ops->is_active_iterate) {
- if (!se->ops->is_active_iterate(se->opaque)) {
- continue;
- }
+ if (se->ops->is_active_iterate &&
+ !se->ops->is_active_iterate(se->opaque)) {
+ continue;
}
/*
* In the postcopy phase, any device that doesn't know how to
@@ -1420,10 +1418,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
return -EINVAL;
}
- if (migration_is_blocked(errp)) {
- return -EINVAL;
- }
-
if (migrate_use_block()) {
error_setg(errp, "Block migration and snapshots are incompatible");
return -EINVAL;
@@ -2268,6 +2262,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
return 0;
}
+static int qemu_loadvm_state_header(QEMUFile *f)
+{
+ unsigned int v;
+ int ret;
+
+ v = qemu_get_be32(f);
+ if (v != QEMU_VM_FILE_MAGIC) {
+ error_report("Not a migration stream");
+ return -EINVAL;
+ }
+
+ v = qemu_get_be32(f);
+ if (v == QEMU_VM_FILE_VERSION_COMPAT) {
+ error_report("SaveVM v2 format is obsolete and don't work anymore");
+ return -ENOTSUP;
+ }
+ if (v != QEMU_VM_FILE_VERSION) {
+ error_report("Unsupported migration stream version");
+ return -ENOTSUP;
+ }
+
+ if (migrate_get_current()->send_configuration) {
+ if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
+ error_report("Configuration section missing");
+ qemu_loadvm_state_cleanup();
+ return -EINVAL;
+ }
+ ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
+
+ if (ret) {
+ qemu_loadvm_state_cleanup();
+ return ret;
+ }
+ }
+ return 0;
+}
+
static int qemu_loadvm_state_setup(QEMUFile *f)
{
SaveStateEntry *se;
@@ -2416,7 +2447,6 @@ int qemu_loadvm_state(QEMUFile *f)
{
MigrationIncomingState *mis = migration_incoming_get_current();
Error *local_err = NULL;
- unsigned int v;
int ret;
if (qemu_savevm_state_blocked(&local_err)) {
@@ -2424,40 +2454,15 @@ int qemu_loadvm_state(QEMUFile *f)
return -EINVAL;
}
- v = qemu_get_be32(f);
- if (v != QEMU_VM_FILE_MAGIC) {
- error_report("Not a migration stream");
- return -EINVAL;
- }
-
- v = qemu_get_be32(f);
- if (v == QEMU_VM_FILE_VERSION_COMPAT) {
- error_report("SaveVM v2 format is obsolete and don't work anymore");
- return -ENOTSUP;
- }
- if (v != QEMU_VM_FILE_VERSION) {
- error_report("Unsupported migration stream version");
- return -ENOTSUP;
+ ret = qemu_loadvm_state_header(f);
+ if (ret) {
+ return ret;
}
if (qemu_loadvm_state_setup(f) != 0) {
return -EINVAL;
}
- if (migrate_get_current()->send_configuration) {
- if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
- error_report("Configuration section missing");
- qemu_loadvm_state_cleanup();
- return -EINVAL;
- }
- ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
-
- if (ret) {
- qemu_loadvm_state_cleanup();
- return ret;
- }
- }
-
cpu_synchronize_all_pre_loadvm();
ret = qemu_loadvm_state_main(f, mis);
@@ -2544,7 +2549,7 @@ int save_snapshot(const char *name, Error **errp)
AioContext *aio_context;
if (migration_is_blocked(errp)) {
- return false;
+ return ret;
}
if (!replay_can_snapshot()) {