[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 04/13] migration: Create a snapshot thread to realize
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [RFC 04/13] migration: Create a snapshot thread to realize saving memory snapshot |
Date: |
Thu, 7 Jan 2016 20:19:59 +0800 |
If users use migrate file:url command, we consider it as creating
live memory snapshot command.
Besides, we only support tcg accel for now.
Signed-off-by: zhanghailiang <address@hidden>
---
include/migration/migration.h | 2 ++
migration/fd.c | 4 ++++
migration/migration.c | 30 ++++++++++++++++++++++++++++--
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 3f372a5..1316d22 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -171,6 +171,7 @@ struct MigrationState
QSIMPLEQ_HEAD(src_page_requests, MigrationSrcPageRequest)
src_page_requests;
/* The RAMBlock used in the last src_page_request */
RAMBlock *last_req_rb;
+ bool in_snapshot; /* for snapshot */
};
void process_incoming_migration(QEMUFile *f);
@@ -215,6 +216,7 @@ void add_migration_state_change_notifier(Notifier *notify);
void remove_migration_state_change_notifier(Notifier *notify);
MigrationState *migrate_init(const MigrationParams *params);
bool migration_in_setup(MigrationState *);
+bool migration_in_snapshot(MigrationState *);
bool migration_has_finished(MigrationState *);
bool migration_has_failed(MigrationState *);
/* True if outgoing migration has entered postcopy phase */
diff --git a/migration/fd.c b/migration/fd.c
index ac38256..6036560 100644
--- a/migration/fd.c
+++ b/migration/fd.c
@@ -69,6 +69,10 @@ void file_start_outgoing_migration(MigrationState *s, const
char *filename,
error_setg_errno(errp, errno, "Failed to open file: %s", filename);
return;
}
+ /* Fix me: just for test
+ * we shouldn't use this to identify if we are do snapshot.
+ */
+ s->in_snapshot = true;
fd_start_outgoing_migration(s, NULL, fd, errp);
}
diff --git a/migration/migration.c b/migration/migration.c
index e54910d..7633043 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -33,6 +33,7 @@
#include "qom/cpu.h"
#include "exec/memory.h"
#include "exec/address-spaces.h"
+#include "hw/boards.h" /* Fix me: Remove this if we support snapshot for KVM */
#define MAX_THROTTLE (32 << 20) /* Migration transfer speed throttling */
@@ -901,6 +902,11 @@ bool migration_in_postcopy(MigrationState *s)
return (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);
}
+bool migration_in_snapshot(MigrationState *s)
+{
+ return s->in_snapshot;
+}
+
MigrationState *migrate_init(const MigrationParams *params)
{
MigrationState *s = migrate_get_current();
@@ -1732,6 +1738,21 @@ static void *migration_thread(void *opaque)
return NULL;
}
+static void *snapshot_thread(void *opaque)
+{
+ rcu_register_thread();
+ /* Fix me: Remove this if we support snapshot for KVM */
+ if (strcmp(current_machine->accel, "tcg")) {
+ error_report("snapshot only support 'tcg' accel for now");
+ goto error;
+ }
+
+ /* TODO: create memory snapshot */
+
+error:
+ rcu_unregister_thread();
+ return NULL;
+}
void migrate_fd_connect(MigrationState *s)
{
/* This is a best 1st approximation. ns to ms */
@@ -1759,8 +1780,13 @@ void migrate_fd_connect(MigrationState *s)
}
migrate_compress_threads_create();
- qemu_thread_create(&s->thread, "migration", migration_thread, s,
- QEMU_THREAD_JOINABLE);
+ if (!s->in_snapshot) {
+ qemu_thread_create(&s->thread, "migration", migration_thread, s,
+ QEMU_THREAD_JOINABLE);
+ } else {
+ qemu_thread_create(&s->thread, "snapshot", snapshot_thread, s,
+ QEMU_THREAD_JOINABLE);
+ }
s->migration_thread_running = true;
}
--
1.8.3.1
- [Qemu-devel] [RFC 00/13] Live memory snapshot based on userfaultfd, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 10/13] snapshot: Enable the write-protect notification capability for VM's RAM, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 04/13] migration: Create a snapshot thread to realize saving memory snapshot,
zhanghailiang <=
- [Qemu-devel] [RFC 05/13] migration: implement initialization work for snapshot, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 11/13] snapshot/migration: Save VM's RAM into snapshot file, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 13/13] snapshot: Remove page's write-protect and copy the content during setup stage, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 03/13] migration: Allow -incoming to work on file: urls, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 01/13] postcopy/migration: Split fault related state into struct UserfaultState, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 09/13] migration/postcopy-ram: fix some helper functions to support userfaultfd write-protect, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 02/13] migration: Allow the migrate command to work on file: urls, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 08/13] snapshot: Save VM's device state into snapshot file, zhanghailiang, 2016/01/07