[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 22/47] Allow savevm handlers to state whether the
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v3 22/47] Allow savevm handlers to state whether they could go into postcopy |
Date: |
Thu, 28 Aug 2014 16:03:39 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Use that to split the qemu_savevm_state_pending counts into postcopiable
and non-postcopiable amounts
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
arch_init.c | 7 +++++++
include/migration/vmstate.h | 2 +-
include/sysemu/sysemu.h | 4 +++-
migration.c | 9 ++++++++-
savevm.c | 23 +++++++++++++++++++----
5 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 2568369..315b88e 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -1190,6 +1190,12 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
return ret;
}
+/* RAM's always up for postcopying */
+static bool ram_can_postcopy(void *opaque)
+{
+ return true;
+}
+
static SaveVMHandlers savevm_ram_handlers = {
.save_live_setup = ram_save_setup,
.save_live_iterate = ram_save_iterate,
@@ -1197,6 +1203,7 @@ static SaveVMHandlers savevm_ram_handlers = {
.save_live_pending = ram_save_pending,
.load_state = ram_load,
.cancel = ram_migration_cancel,
+ .can_postcopy = ram_can_postcopy,
};
void ram_mig_init(void)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 9a001bd..4991935 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -54,7 +54,7 @@ typedef struct SaveVMHandlers {
/* This runs outside the iothread lock! */
int (*save_live_setup)(QEMUFile *f, void *opaque);
uint64_t (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t
max_size);
-
+ bool (*can_postcopy)(void *opaque);
LoadStateHandler *load_state;
} SaveVMHandlers;
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index abf0d63..dc53580 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -109,7 +109,9 @@ void qemu_savevm_state_begin(QEMUFile *f,
int qemu_savevm_state_iterate(QEMUFile *f);
void qemu_savevm_state_complete(QEMUFile *f);
void qemu_savevm_state_cancel(void);
-uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
+void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size,
+ uint64_t *res_non_postcopiable,
+ uint64_t *res_postcopiable);
void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command,
uint16_t len, uint8_t *data);
void qemu_savevm_send_reqack(QEMUFile *f, uint32_t value);
diff --git a/migration.c b/migration.c
index 6097c3c..6c6ec03 100644
--- a/migration.c
+++ b/migration.c
@@ -840,8 +840,15 @@ static void *migration_thread(void *opaque)
uint64_t pending_size;
if (!qemu_file_rate_limit(s->file)) {
- pending_size = qemu_savevm_state_pending(s->file, max_size);
+ uint64_t pend_post, pend_nonpost;
+ DPRINTF("iterate\n");
+ qemu_savevm_state_pending(s->file, max_size, &pend_nonpost,
+ &pend_post);
+ pending_size = pend_nonpost + pend_post;
trace_migrate_pending(pending_size, max_size);
+ DPRINTF("pending size %" PRIu64 " max %" PRIu64 " (post=%" PRIu64
+ " nonpost=%" PRIu64 ")\n",
+ pending_size, max_size, pend_post, pend_nonpost);
if (pending_size && pending_size >= max_size) {
qemu_savevm_state_iterate(s->file);
} else {
diff --git a/savevm.c b/savevm.c
index 809bd04..412bf9d 100644
--- a/savevm.c
+++ b/savevm.c
@@ -903,10 +903,18 @@ void qemu_savevm_state_complete(QEMUFile *f)
qemu_fflush(f);
}
-uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size)
+/* Give an estimate of the amount left to be transferred,
+ * the result is split into the amount for units that can and
+ * for units that can't do postcopy.
+ */
+void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size,
+ uint64_t *res_non_postcopiable,
+ uint64_t *res_postcopiable)
{
SaveStateEntry *se;
- uint64_t ret = 0;
+ uint64_t res_nonpc = 0;
+ uint64_t res_pc = 0;
+ uint64_t tmp;
QTAILQ_FOREACH(se, &savevm_handlers, entry) {
if (!se->ops || !se->ops->save_live_pending) {
@@ -917,9 +925,16 @@ uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t
max_size)
continue;
}
}
- ret += se->ops->save_live_pending(f, se->opaque, max_size);
+ tmp = se->ops->save_live_pending(f, se->opaque, max_size);
+
+ if (se->ops->can_postcopy(se->opaque)) {
+ res_pc += tmp;
+ } else {
+ res_nonpc += tmp;
+ }
}
- return ret;
+ *res_non_postcopiable = res_nonpc;
+ *res_postcopiable = res_pc;
}
void qemu_savevm_state_cancel(void)
--
1.9.3
- [Qemu-devel] [PATCH v3 10/47] Return path: socket_writev_buffer: Block even on non-blocking fd's, (continued)
- [Qemu-devel] [PATCH v3 10/47] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 14/47] Return path: Source handling of return path, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 09/47] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 12/47] Return path: Control commands, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 13/47] Return path: Send responses from destination to source, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 16/47] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 17/47] Rework loadvm path for subloops, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 06/47] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 18/47] Add migration-capability boolean for postcopy-ram., Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 20/47] QEMU_VM_CMD_PACKAGED: Send a packaged chunk of migration stream, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 22/47] Allow savevm handlers to state whether they could go into postcopy,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v3 23/47] postcopy: OS support test, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 11/47] Migration commands, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 21/47] migrate_init: Call from savevm, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 24/47] migrate_start_postcopy: Command to trigger transition to postcopy, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 25/47] MIG_STATE_POSTCOPY_ACTIVE: Add new migration state, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 27/47] Postcopy: Maintain sentmap during postcopy pre phase, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 28/47] Postcopy page-map-incoming (PMI) structure, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 29/47] postcopy: Add incoming_init/cleanup functions, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 26/47] qemu_savevm_state_complete: Postcopy changes, Dr. David Alan Gilbert (git), 2014/08/28
- [Qemu-devel] [PATCH v3 15/47] qemu_loadvm errors and debug, Dr. David Alan Gilbert (git), 2014/08/28