[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 07/47] Create MigrationIncomingState
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v4 07/47] Create MigrationIncomingState |
Date: |
Fri, 3 Oct 2014 18:47:13 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
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
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
include/migration/migration.h | 9 +++++++++
include/qemu/typedefs.h | 2 ++
migration.c | 28 ++++++++++++++++++++++++++++
savevm.c | 2 ++
4 files changed, 41 insertions(+)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 3cb5ba8..8a36255 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -41,6 +41,15 @@ struct MigrationParams {
typedef struct MigrationState MigrationState;
+/* State for the incoming migration */
+struct MigrationIncomingState {
+ QEMUFile *file;
+};
+
+MigrationIncomingState *migration_incoming_get_current(void);
+MigrationIncomingState *migration_incoming_state_init(QEMUFile *f);
+void migration_incoming_state_destroy(void);
+
struct MigrationState
{
int64_t bandwidth_limit;
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..ac46ddb 100644
--- a/migration.c
+++ b/migration.c
@@ -65,6 +65,7 @@ static NotifierList migration_state_notifiers =
migrations at once. For now we don't need to add
dynamic creation of migration */
+/* For outgoing */
MigrationState *migrate_get_current(void)
{
static MigrationState current_migration = {
@@ -77,6 +78,28 @@ MigrationState *migrate_get_current(void)
return ¤t_migration;
}
+/* For incoming */
+static MigrationIncomingState *mis_current;
+
+MigrationIncomingState *migration_incoming_get_current(void)
+{
+ return mis_current;
+}
+
+MigrationIncomingState *migration_incoming_state_init(QEMUFile* f)
+{
+ mis_current = g_malloc0(sizeof(MigrationIncomingState));
+ mis_current->file = f;
+
+ return mis_current;
+}
+
+void migration_incoming_state_destroy(void)
+{
+ g_free(mis_current);
+ mis_current = NULL;
+}
+
void qemu_start_incoming_migration(const char *uri, Error **errp)
{
const char *p;
@@ -106,9 +129,14 @@ static void process_incoming_migration_co(void *opaque)
Error *local_err = NULL;
int ret;
+ migration_incoming_state_init(f);
+
ret = qemu_loadvm_state(f);
+
qemu_fclose(f);
free_xbzrle_decoded_buf();
+ migration_incoming_state_destroy();
+
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..a0c3b40 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1244,9 +1244,11 @@ int load_vmstate(const char *name)
}
qemu_system_reset(VMRESET_SILENT);
+ migration_incoming_state_init(f);
ret = qemu_loadvm_state(f);
qemu_fclose(f);
+ migration_incoming_state_destroy();
if (ret < 0) {
error_report("Error %d while loading VM state", ret);
return ret;
--
1.9.3
- [Qemu-devel] [PATCH v4 00/47] Postcopy implementation, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 01/47] QEMUSizedBuffer based QEMUFile, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 02/47] Tests: QEMUSizedBuffer/QEMUBuffer, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 03/47] Start documenting how postcopy works., Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 05/47] improve DPRINTF macros, add to savevm, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 04/47] qemu_ram_foreach_block: pass up error value, and down the ramblock name, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 06/47] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 07/47] Create MigrationIncomingState,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v4 08/47] socket shutdown, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 09/47] Provide runtime Target page information, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 10/47] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 12/47] Handle bi-directional communication for fd migration, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 11/47] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 13/47] Migration commands, Dr. David Alan Gilbert (git), 2014/10/03
- [Qemu-devel] [PATCH v4 14/47] Return path: Control commands, Dr. David Alan Gilbert (git), 2014/10/03