@@ -1419,7 +1419,7 @@ void qemu_remove_machine_init_done_notifier(Notifier *notify)
void qdev_machine_creation_done(void)
{
- cpu_synchronize_all_post_init();
+ cpu_synchronize_all_post_init(NULL);
if (current_machine->boot_config.has_once) {
qemu_boot_set(current_machine->boot_config.once, &error_fatal);
@@ -45,7 +45,7 @@ bool cpus_are_resettable(void);
void cpu_synchronize_all_states(void);
void cpu_synchronize_all_post_reset(void);
-void cpu_synchronize_all_post_init(void);
+void cpu_synchronize_all_post_init(Error **errp);
void cpu_synchronize_all_pre_loadvm(void);
#ifndef CONFIG_USER_ONLY
@@ -2005,7 +2005,17 @@ static void loadvm_postcopy_handle_run_bh(void *opaque)
/* TODO we should move all of this lot into postcopy_ram.c or a shared code
* in migration.c
*/
- cpu_synchronize_all_post_init();
+ cpu_synchronize_all_post_init(&local_err);
+ if (local_err) {
+ /*
+ * TODO: a better way to do this is to tell the src that we cannot
+ * run the VM here so hopefully we can keep the VM running on src
+ * and immediately halt the switch-over. But that needs work.
+ */
+ error_report_err(local_err);
+ local_err = NULL;
+ autostart = false;
+ }
trace_loadvm_postcopy_handle_run_bh("after cpu sync");
@@ -2772,7 +2782,11 @@ int qemu_loadvm_state(QEMUFile *f)
}
qemu_loadvm_state_cleanup();
- cpu_synchronize_all_post_init();
+ cpu_synchronize_all_post_init(&local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ return -EINVAL;
+ }
return ret;
}
@@ -2789,7 +2803,7 @@ int qemu_load_device_state(QEMUFile *f)
return ret;
}
- cpu_synchronize_all_post_init();
+ cpu_synchronize_all_post_init(NULL);
return 0;
}
@@ -146,7 +146,7 @@ void cpu_synchronize_all_post_reset(void)
}
}
-void cpu_synchronize_all_post_init(void)
+void cpu_synchronize_all_post_init(Error **errp)
{
CPUState *cpu;
Allow cpu_synchronize_all_post_init() to fail with an errp when it's set. Modify both precopy and postcopy to try to detect such error. Signed-off-by: Peter Xu <peterx@redhat.com> --- hw/core/machine.c | 2 +- include/sysemu/cpus.h | 2 +- migration/savevm.c | 20 +++++++++++++++++--- softmmu/cpus.c | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-)