From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> There are currently lots of pieces of incoming migration state scattered around, and postcopy is adding more, and it seems better to try and keep it together.
allocate MIS in process_incoming_migration_co Add MIS to QEMUFile Signed-off-by: Dr. David Alan Gilbert <dgilb...@redhat.com> --- include/migration/migration.h | 8 ++++++++ include/migration/qemu-file.h | 2 ++ include/qemu/typedefs.h | 2 ++ migration.c | 22 ++++++++++++++++++++++ savevm.c | 2 ++ 5 files changed, 36 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 3cb5ba8..4103460 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -41,6 +41,14 @@ struct MigrationParams { typedef struct MigrationState MigrationState; +/* State for the incoming migration */ +struct MigrationIncomingState { + QEMUFile *file; +}; + +MigrationIncomingState *migration_incoming_state_init(QEMUFile *f); +void migration_incoming_state_destroy(MigrationIncomingState *mis); + struct MigrationState { int64_t bandwidth_limit; diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index e6d3a5c..df38646 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -116,6 +116,8 @@ struct QEMUFile { unsigned int iovcnt; int last_error; + + MigrationIncomingState *mis; }; struct QEMUSizedBuffer { diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index db1153a..0f79b5c 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -14,6 +14,7 @@ typedef struct Visitor Visitor; struct Monitor; typedef struct Monitor Monitor; +typedef struct MigrationIncomingState MigrationIncomingState; typedef struct MigrationParams MigrationParams; typedef struct Property Property; @@ -44,6 +45,7 @@ typedef struct PixelFormat PixelFormat; typedef struct QemuConsole QemuConsole; typedef struct CharDriverState CharDriverState; typedef struct MACAddr MACAddr; +typedef struct MigrationIncomingState MigrationIncomingState; typedef struct NetClientState NetClientState; typedef struct I2CBus I2CBus; typedef struct ISABus ISABus; diff --git a/migration.c b/migration.c index e241370..c5b133d 100644 --- a/migration.c +++ b/migration.c @@ -100,15 +100,37 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) } } +MigrationIncomingState *migration_incoming_state_init(QEMUFile* f) +{ + MigrationIncomingState *mis = g_malloc0(sizeof(MigrationIncomingState)); + mis->file = f; + + return mis; +} + +void migration_incoming_state_destroy(MigrationIncomingState *mis) +{ + g_free(mis); +} + static void process_incoming_migration_co(void *opaque) { QEMUFile *f = opaque; Error *local_err = NULL; + MigrationIncomingState *mis; int ret; + mis = migration_incoming_state_init(f); + f->mis = mis; + ret = qemu_loadvm_state(f); + + f->mis = NULL; qemu_fclose(f); free_xbzrle_decoded_buf(); + migration_incoming_state_destroy(mis); + mis = NULL; + if (ret < 0) { error_report("load of migration failed: %s", strerror(-ret)); exit(EXIT_FAILURE); diff --git a/savevm.c b/savevm.c index cb6f0de..46cb9b0 100644 --- a/savevm.c +++ b/savevm.c @@ -1244,9 +1244,11 @@ int load_vmstate(const char *name) } qemu_system_reset(VMRESET_SILENT); + f->mis = migration_incoming_state_init(f); ret = qemu_loadvm_state(f); qemu_fclose(f); + migration_incoming_state_destroy(f->mis); if (ret < 0) { error_report("Error %d while loading VM state", ret); return ret; -- 1.9.3