diff options
Diffstat (limited to 'migration/savevm.c')
-rw-r--r-- | migration/savevm.c | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/migration/savevm.c b/migration/savevm.c index be3f885119..fdd15fa0a7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -596,7 +596,7 @@ int register_savevm_live(DeviceState *dev, se->opaque = opaque; se->vmsd = NULL; /* if this is a live_savem then set is_ram */ - if (ops->save_live_setup != NULL) { + if (ops->save_setup != NULL) { se->is_ram = 1; } @@ -955,14 +955,14 @@ void qemu_savevm_state_header(QEMUFile *f) } } -void qemu_savevm_state_begin(QEMUFile *f) +void qemu_savevm_state_setup(QEMUFile *f) { SaveStateEntry *se; int ret; - trace_savevm_state_begin(); + trace_savevm_state_setup(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->save_live_setup) { + if (!se->ops || !se->ops->save_setup) { continue; } if (se->ops && se->ops->is_active) { @@ -972,7 +972,7 @@ void qemu_savevm_state_begin(QEMUFile *f) } save_section_header(f, se, QEMU_VM_SECTION_START); - ret = se->ops->save_live_setup(f, se->opaque); + ret = se->ops->save_setup(f, se->opaque); save_section_footer(f, se); if (ret < 0) { qemu_file_set_error(f, ret); @@ -1215,8 +1215,8 @@ void qemu_savevm_state_cleanup(void) trace_savevm_state_cleanup(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (se->ops && se->ops->cleanup) { - se->ops->cleanup(se->opaque); + if (se->ops && se->ops->save_cleanup) { + se->ops->save_cleanup(se->opaque); } } } @@ -1241,7 +1241,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) qemu_mutex_unlock_iothread(); qemu_savevm_state_header(f); - qemu_savevm_state_begin(f); + qemu_savevm_state_setup(f); qemu_mutex_lock_iothread(); while (qemu_file_get_error(f) == 0) { @@ -1541,7 +1541,7 @@ static void *postcopy_ram_listen_thread(void *opaque) * got a bad migration state). */ migration_incoming_state_destroy(); - + qemu_loadvm_state_cleanup(); return NULL; } @@ -1901,6 +1901,44 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) return 0; } +static int qemu_loadvm_state_setup(QEMUFile *f) +{ + SaveStateEntry *se; + int ret; + + trace_loadvm_state_setup(); + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->load_setup) { + continue; + } + if (se->ops && se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } + + ret = se->ops->load_setup(f, se->opaque); + if (ret < 0) { + qemu_file_set_error(f, ret); + error_report("Load state of device %s failed", se->idstr); + return ret; + } + } + return 0; +} + +void qemu_loadvm_state_cleanup(void) +{ + SaveStateEntry *se; + + trace_loadvm_state_cleanup(); + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (se->ops && se->ops->load_cleanup) { + se->ops->load_cleanup(se->opaque); + } + } +} + static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) { uint8_t section_type; @@ -1973,6 +2011,10 @@ int qemu_loadvm_state(QEMUFile *f) return -ENOTSUP; } + 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"); @@ -2036,6 +2078,7 @@ int qemu_loadvm_state(QEMUFile *f) } } + qemu_loadvm_state_cleanup(); cpu_synchronize_all_post_init(); return ret; |