int64_t setup_start;
MigThrError thr_error;
QEMUFile *fb;
- bool early_fail = true;
Error *local_err = NULL;
int ret;
* devices to unplug. This to preserve migration state transitions.
*/
if (ret) {
- migrate_error_propagate(s, local_err);
- migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
- MIGRATION_STATUS_FAILED);
- goto fail_setup;
+ goto fail;
}
s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
bql_lock();
if (migration_stop_vm(s, RUN_STATE_PAUSED)) {
- goto fail;
+ error_setg(&local_err, "Failed to stop the VM");
+ goto fail_with_bql;
}
if (qemu_savevm_state_non_iterable(fb)) {
- goto fail;
+ error_setg(&local_err, "Failed to save non-iterable devices");
+ goto fail_with_bql;
}
qemu_savevm_state_end_precopy(s, fb);
/* Now initialize UFFD context and start tracking RAM writes */
if (ram_write_tracking_start()) {
- goto fail;
+ error_setg(&local_err, "Failed to start write tracking");
+ goto fail_with_bql;
}
- early_fail = false;
/*
* Start VM from BH handler to avoid write-fault lock here.
}
trace_migration_thread_after_loop();
+ goto done;
+
+fail_with_bql:
+ bql_unlock();
fail:
- if (early_fail) {
- migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
- MIGRATION_STATUS_FAILED);
- bql_unlock();
- }
+ /* local_err is guaranteed to be set when reaching here */
+ migrate_error_propagate(s, local_err);
+ migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
+ MIGRATION_STATUS_FAILED);
-fail_setup:
+done:
bg_migration_iteration_finish(s);
-
qemu_fclose(fb);
object_unref(OBJECT(s));
rcu_unregister_thread();
-
return NULL;
}