From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, david@gibson.dropbear.id.au, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 4/6] Create MigrationIncomingState
Date: Thu, 21 May 2015 13:24:14 +0100 [thread overview]
Message-ID: <1432211056-6265-5-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1432211056-6265-1-git-send-email-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@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
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
---
include/migration/migration.h | 9 +++++++++
include/qemu/typedefs.h | 1 +
migration/migration.c | 28 ++++++++++++++++++++++++++++
savevm.c | 2 ++
4 files changed, 40 insertions(+)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index a6e025a..00fb6a0 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -42,6 +42,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_new(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 cde3314..74dfad3 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -38,6 +38,7 @@ typedef struct MemoryListener MemoryListener;
typedef struct MemoryMappingList MemoryMappingList;
typedef struct MemoryRegion MemoryRegion;
typedef struct MemoryRegionSection MemoryRegionSection;
+typedef struct MigrationIncomingState MigrationIncomingState;
typedef struct MigrationParams MigrationParams;
typedef struct Monitor Monitor;
typedef struct MouseTransformInfo MouseTransformInfo;
diff --git a/migration/migration.c b/migration/migration.c
index 1660d74..9cf4743 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -53,6 +53,7 @@ static bool deferred_incoming;
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 = {
@@ -71,6 +72,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_new(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;
+}
+
/*
* Called on -incoming with a defer: uri.
* The migration can be started later after any parameters have been
@@ -115,9 +138,14 @@ static void process_incoming_migration_co(void *opaque)
Error *local_err = NULL;
int ret;
+ migration_incoming_state_new(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));
migrate_decompress_threads_join();
diff --git a/savevm.c b/savevm.c
index d9f0cca..2aa2d19 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1320,9 +1320,11 @@ int load_vmstate(const char *name)
}
qemu_system_reset(VMRESET_SILENT);
+ migration_incoming_state_new(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;
--
2.4.1
next prev parent reply other threads:[~2015-05-21 12:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-21 12:24 [Qemu-devel] [PATCH 0/6] Migration cleanups for postcopy Dr. David Alan Gilbert (git)
2015-05-21 12:24 ` [Qemu-devel] [PATCH 1/6] Add qemu_get_counted_string to read a string prefixed by a count byte Dr. David Alan Gilbert (git)
2015-05-25 0:47 ` David Gibson
2015-06-03 9:44 ` Juan Quintela
2015-05-21 12:24 ` [Qemu-devel] [PATCH 2/6] Split header writing out of qemu_savevm_state_begin Dr. David Alan Gilbert (git)
2015-05-25 0:47 ` David Gibson
2015-06-03 9:58 ` Juan Quintela
2015-05-21 12:24 ` [Qemu-devel] [PATCH 3/6] qemu_ram_foreach_block: pass up error value, and down the ramblock name Dr. David Alan Gilbert (git)
2015-06-03 10:01 ` Juan Quintela
2015-05-21 12:24 ` Dr. David Alan Gilbert (git) [this message]
2015-05-25 0:50 ` [Qemu-devel] [PATCH 4/6] Create MigrationIncomingState David Gibson
2015-06-03 10:17 ` Juan Quintela
2015-05-21 12:24 ` [Qemu-devel] [PATCH 5/6] Move copy out of qemu_peek_buffer Dr. David Alan Gilbert (git)
2015-06-03 10:19 ` Juan Quintela
2015-05-21 12:24 ` [Qemu-devel] [PATCH 6/6] Move loadvm_handlers into MigrationIncomingState Dr. David Alan Gilbert (git)
2015-06-03 11:27 ` Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432211056-6265-5-git-send-email-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=amit.shah@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).