aboutsummaryrefslogtreecommitdiff
path: root/migration/savevm.c
diff options
context:
space:
mode:
Diffstat (limited to 'migration/savevm.c')
-rw-r--r--migration/savevm.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/migration/savevm.c b/migration/savevm.c
index 9992af4..ef707b8 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1327,21 +1327,25 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
MigrationState *ms = migrate_get_current();
MigrationStatus status;
- migrate_init(ms);
-
- ms->to_dst_file = f;
+ if (migration_is_setup_or_active(ms->state) ||
+ ms->state == MIGRATION_STATUS_CANCELLING ||
+ ms->state == MIGRATION_STATUS_COLO) {
+ error_setg(errp, QERR_MIGRATION_ACTIVE);
+ return -EINVAL;
+ }
if (migration_is_blocked(errp)) {
- ret = -EINVAL;
- goto done;
+ return -EINVAL;
}
if (migrate_use_block()) {
error_setg(errp, "Block migration and snapshots are incompatible");
- ret = -EINVAL;
- goto done;
+ return -EINVAL;
}
+ migrate_init(ms);
+ ms->to_dst_file = f;
+
qemu_mutex_unlock_iothread();
qemu_savevm_state_header(f);
qemu_savevm_state_setup(f);
@@ -1363,7 +1367,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
error_setg_errno(errp, -ret, "Error while writing VM state");
}
-done:
if (ret != 0) {
status = MIGRATION_STATUS_FAILED;
} else {