[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 25/45] qemu_savevm_state_complete: Postcopy chang
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v5 25/45] qemu_savevm_state_complete: Postcopy changes |
Date: |
Wed, 25 Feb 2015 16:51:48 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
When postcopy calls qemu_savevm_state_complete it's not really
the end of migration, so skip:
a) Finishing postcopiable iterative devices - they'll carry on
b) The termination byte on the end of the stream.
We then also add:
qemu_savevm_state_postcopy_complete
which is called at the end of a postcopy migration to call the
complete methods on devices skipped in the _complete call.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
include/sysemu/sysemu.h | 1 +
savevm.c | 61 ++++++++++++++++++++++++++++++++++++++++++++-----
trace-events | 1 +
3 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 5f518b3..0f2e4ed 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -114,6 +114,7 @@ void qemu_savevm_state_cancel(void);
void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size,
uint64_t *res_non_postcopiable,
uint64_t *res_postcopiable);
+void qemu_savevm_state_postcopy_complete(QEMUFile *f);
void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command,
uint16_t len, uint8_t *data);
void qemu_savevm_send_ping(QEMUFile *f, uint32_t value);
diff --git a/savevm.c b/savevm.c
index 2ea4c76..1e8d289 100644
--- a/savevm.c
+++ b/savevm.c
@@ -865,12 +865,54 @@ int qemu_savevm_state_iterate(QEMUFile *f)
return ret;
}
+/*
+ * Calls the complete routines just for those devices that are postcopiable;
+ * causing the last few pages to be sent immediately and doing any associated
+ * cleanup.
+ * Note postcopy also calls the plain qemu_savevm_state_complete to complete
+ * all the other devices, but that happens at the point we switch to postcopy.
+ */
+void qemu_savevm_state_postcopy_complete(QEMUFile *f)
+{
+ SaveStateEntry *se;
+ int ret;
+
+ QTAILQ_FOREACH(se, &savevm_handlers, entry) {
+ if (!se->ops || !se->ops->save_live_complete ||
+ !(se->ops->can_postcopy &&
+ se->ops->can_postcopy(se->opaque))) {
+ continue;
+ }
+ if (se->ops && se->ops->is_active) {
+ if (!se->ops->is_active(se->opaque)) {
+ continue;
+ }
+ }
+ trace_savevm_section_start(se->idstr, se->section_id);
+ /* Section type */
+ qemu_put_byte(f, QEMU_VM_SECTION_END);
+ qemu_put_be32(f, se->section_id);
+
+ ret = se->ops->save_live_complete(f, se->opaque);
+ trace_savevm_section_end(se->idstr, se->section_id, ret);
+ if (ret < 0) {
+ qemu_file_set_error(f, ret);
+ return;
+ }
+ }
+
+ qemu_savevm_send_postcopy_end(f, 0 /* Good */);
+ qemu_put_byte(f, QEMU_VM_EOF);
+ qemu_fflush(f);
+}
+
void qemu_savevm_state_complete(QEMUFile *f)
{
QJSON *vmdesc;
int vmdesc_len;
SaveStateEntry *se;
int ret;
+ bool in_postcopy = migration_postcopy_phase(migrate_get_current());
trace_savevm_state_complete();
@@ -885,6 +927,11 @@ void qemu_savevm_state_complete(QEMUFile *f)
continue;
}
}
+ if (in_postcopy && se->ops && se->ops->can_postcopy &&
+ se->ops->can_postcopy(se->opaque)) {
+ trace_qemu_savevm_state_complete_skip_for_postcopy(se->idstr);
+ continue;
+ }
trace_savevm_section_start(se->idstr, se->section_id);
/* Section type */
qemu_put_byte(f, QEMU_VM_SECTION_END);
@@ -931,15 +978,17 @@ void qemu_savevm_state_complete(QEMUFile *f)
trace_savevm_section_end(se->idstr, se->section_id, 0);
}
- qemu_put_byte(f, QEMU_VM_EOF);
-
json_end_array(vmdesc);
qjson_finish(vmdesc);
- vmdesc_len = strlen(qjson_get_str(vmdesc));
+ if (!in_postcopy) {
+ /* Postcopy stream will still be going */
+ qemu_put_byte(f, QEMU_VM_EOF);
+ vmdesc_len = strlen(qjson_get_str(vmdesc));
- qemu_put_byte(f, QEMU_VM_VMDESCRIPTION);
- qemu_put_be32(f, vmdesc_len);
- qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len);
+ qemu_put_byte(f, QEMU_VM_VMDESCRIPTION);
+ qemu_put_be32(f, vmdesc_len);
+ qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len);
+ }
object_unref(OBJECT(vmdesc));
qemu_fflush(f);
diff --git a/trace-events b/trace-events
index 941976a..a555b56 100644
--- a/trace-events
+++ b/trace-events
@@ -1185,6 +1185,7 @@ loadvm_process_command(uint16_t com, uint16_t len)
"com=0x%x len=%d"
loadvm_process_command_ping(uint32_t val) "%x"
qemu_savevm_send_postcopy_advise(void) ""
qemu_savevm_send_postcopy_ram_discard(void) ""
+qemu_savevm_state_complete_skip_for_postcopy(const char *section) "skipping:
%s"
savevm_section_start(const char *id, unsigned int section_id) "%s, section_id
%u"
savevm_section_end(const char *id, unsigned int section_id, int ret) "%s,
section_id %u -> %d"
savevm_send_ping(uint32_t val) "%x"
--
2.1.0
- [Qemu-devel] [PATCH v5 15/45] Rework loadvm path for subloops, (continued)
- [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
- [Qemu-devel] [PATCH v5 25/45] qemu_savevm_state_complete: Postcopy changes,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v5 26/45] Postcopy page-map-incoming (PMI) structure, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 29/45] postcopy: ram_enable_notify to switch on userfault, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 28/45] postcopy: Incoming initialisation, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 27/45] Postcopy: Maintain sentmap and calculate discard, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 30/45] Postcopy: Postcopy startup in migration thread, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 31/45] Postcopy end in migration_thread, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 32/45] Page request: Add MIG_RP_CMD_REQ_PAGES reverse command, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 33/45] Page request: Process incoming page request, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 34/45] Page request: Consume pages off the post-copy queue, Dr. David Alan Gilbert (git), 2015/02/25
- [Qemu-devel] [PATCH v5 35/45] postcopy_ram.c: place_page and helpers, Dr. David Alan Gilbert (git), 2015/02/25