[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 14/45] Move loadvm_handlers into MigrationIncomin
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v5 14/45] Move loadvm_handlers into MigrationIncomingState |
Date: |
Wed, 25 Feb 2015 16:51:37 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
In postcopy we need the loadvm_handlers to be used in a couple
of different instances of the loadvm loop/routine, and thus
it can't be local any more.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
include/migration/migration.h | 5 +++++
include/migration/vmstate.h | 2 ++
include/qemu/typedefs.h | 1 +
migration/migration.c | 2 ++
savevm.c | 28 ++++++++++++++++------------
5 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 3776e86..751caa0 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -50,10 +50,15 @@ enum mig_rpcomm_cmd {
typedef struct MigrationState MigrationState;
+typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head;
+
/* State for the incoming migration */
struct MigrationIncomingState {
QEMUFile *file;
+ /* See savevm.c */
+ LoadStateEntry_Head loadvm_handlers;
+
QEMUFile *return_path;
QemuMutex rp_mutex; /* We send replies from multiple threads */
};
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index c20f2d1..18da207 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -797,6 +797,8 @@ extern const VMStateInfo vmstate_info_bitmap;
#define SELF_ANNOUNCE_ROUNDS 5
+void loadvm_free_handlers(MigrationIncomingState *mis);
+
int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, int version_id);
void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 74dfad3..6fdcbcd 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -31,6 +31,7 @@ typedef struct I2CBus I2CBus;
typedef struct I2SCodec I2SCodec;
typedef struct ISABus ISABus;
typedef struct ISADevice ISADevice;
+typedef struct LoadStateEntry LoadStateEntry;
typedef struct MACAddr MACAddr;
typedef struct MachineClass MachineClass;
typedef struct MachineState MachineState;
diff --git a/migration/migration.c b/migration/migration.c
index 34cd4fe..4592060 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -78,6 +78,7 @@ MigrationIncomingState
*migration_incoming_state_new(QEMUFile* f)
{
mis_current = g_malloc0(sizeof(MigrationIncomingState));
mis_current->file = f;
+ QLIST_INIT(&mis_current->loadvm_handlers);
qemu_mutex_init(&mis_current->rp_mutex);
return mis_current;
@@ -85,6 +86,7 @@ MigrationIncomingState
*migration_incoming_state_new(QEMUFile* f)
void migration_incoming_state_destroy(void)
{
+ loadvm_free_handlers(mis_current);
g_free(mis_current);
mis_current = NULL;
}
diff --git a/savevm.c b/savevm.c
index 7084d07..f42713d 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1019,18 +1019,26 @@ static int loadvm_process_command(QEMUFile *f)
return 0;
}
-typedef struct LoadStateEntry {
+struct LoadStateEntry {
QLIST_ENTRY(LoadStateEntry) entry;
SaveStateEntry *se;
int section_id;
int version_id;
-} LoadStateEntry;
+};
-int qemu_loadvm_state(QEMUFile *f)
+void loadvm_free_handlers(MigrationIncomingState *mis)
{
- QLIST_HEAD(, LoadStateEntry) loadvm_handlers =
- QLIST_HEAD_INITIALIZER(loadvm_handlers);
LoadStateEntry *le, *new_le;
+
+ QLIST_FOREACH_SAFE(le, &mis->loadvm_handlers, entry, new_le) {
+ QLIST_REMOVE(le, entry);
+ g_free(le);
+ }
+}
+
+int qemu_loadvm_state(QEMUFile *f)
+{
+ MigrationIncomingState *mis = migration_incoming_get_current();
Error *local_err = NULL;
uint8_t section_type;
unsigned int v;
@@ -1061,6 +1069,7 @@ int qemu_loadvm_state(QEMUFile *f)
while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
uint32_t instance_id, version_id, section_id;
SaveStateEntry *se;
+ LoadStateEntry *le;
char idstr[256];
trace_qemu_loadvm_state_section(section_type);
@@ -1102,7 +1111,7 @@ int qemu_loadvm_state(QEMUFile *f)
le->se = se;
le->section_id = section_id;
le->version_id = version_id;
- QLIST_INSERT_HEAD(&loadvm_handlers, le, entry);
+ QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry);
ret = vmstate_load(f, le->se, le->version_id);
if (ret < 0) {
@@ -1116,7 +1125,7 @@ int qemu_loadvm_state(QEMUFile *f)
section_id = qemu_get_be32(f);
trace_qemu_loadvm_state_section_partend(section_id);
- QLIST_FOREACH(le, &loadvm_handlers, entry) {
+ QLIST_FOREACH(le, &mis->loadvm_handlers, entry) {
if (le->section_id == section_id) {
break;
}
@@ -1152,11 +1161,6 @@ int qemu_loadvm_state(QEMUFile *f)
ret = 0;
out:
- QLIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) {
- QLIST_REMOVE(le, entry);
- g_free(le);
- }
-
if (ret == 0) {
ret = qemu_file_get_error(f);
}
--
2.1.0
- [Qemu-devel] [PATCH v5 02/45] Split header writing out of qemu_save_state_begin, (continued)
- [Qemu-devel] [PATCH v5 02/45] Split header writing out of qemu_save_state_begin, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 04/45] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 06/45] Provide runtime Target page information, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 09/45] Migration commands, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 07/45] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 10/45] Return path: Control commands, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 08/45] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 13/45] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 11/45] Return path: Send responses from destination to source, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 12/45] Return path: Source handling of return path, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 14/45] Move loadvm_handlers into MigrationIncomingState,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v5 15/45] Rework loadvm path for subloops, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 19/45] migrate_init: Call from savevm, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 18/45] MIG_CMD_PACKAGED: Send a packaged chunk of migration stream, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 16/45] Add migration-capability boolean for postcopy-ram., Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 17/45] Add wrappers and handlers for sending/receiving the postcopy-ram migration messages., Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 21/45] Add Linux userfaultfd header, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 20/45] Modify savevm handlers for postcopy, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 24/45] MIG_STATE_POSTCOPY_ACTIVE: Add new migration state, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 22/45] postcopy: OS support test, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 23/45] migrate_start_postcopy: Command to trigger transition to postcopy, Dr. David Alan Gilbert (git), 2015/02/25