diff options
author | Juan Quintela <quintela@redhat.com> | 2017-06-28 11:52:26 +0200 |
---|---|---|
committer | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2017-07-10 17:52:21 +0100 |
commit | acb5ea86971a7f3d0eac30996c4d0eab7b873879 (patch) | |
tree | 34a5d6dc816da696f607201a907fd3fbbc4d8dcf /migration/savevm.c | |
parent | 70f794fcfa7c1b9d7af465d124a0e6175da30e39 (diff) |
migration: Create load_setup()/cleanup() methods
We need to do things at load time and at cleanup time.
Signed-off-by: Juan Quintela <quintela@redhat.com>
--
Move the printing of the error message so we can print the device
giving the error.
Add call to postcopy stuff
Message-Id: <20170628095228.4661-4-quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'migration/savevm.c')
-rw-r--r-- | migration/savevm.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/migration/savevm.c b/migration/savevm.c index fee11c5d28..fdd15fa0a7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -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; |