[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 07/13] savevm: Split qemu_savevm_state_complete_precop
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [RFC 07/13] savevm: Split qemu_savevm_state_complete_precopy() into two helper functions |
Date: |
Thu, 7 Jan 2016 20:20:02 +0800 |
We splited qemu_savevm_state_complete_precopy() into two helper functions,
qemu_savevm_section_full() and qemu_savevm_section_end().
The main reason to do that is, sometimes we may want to do this two works
separately.
Signed-off-by: zhanghailiang <address@hidden>
---
migration/savevm.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 9b22498..1b4e5bd 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1026,18 +1026,12 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f)
qemu_fflush(f);
}
-void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only)
+static int qemu_savevm_section_end(QEMUFile *f, bool iterable_only)
{
- QJSON *vmdesc;
- int vmdesc_len;
SaveStateEntry *se;
int ret;
bool in_postcopy = migration_in_postcopy(migrate_get_current());
- trace_savevm_state_complete_precopy();
-
- cpu_synchronize_all_states();
-
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (!se->ops ||
(in_postcopy && se->ops->save_live_complete_postcopy) ||
@@ -1060,13 +1054,18 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f,
bool iterable_only)
save_section_footer(f, se);
if (ret < 0) {
qemu_file_set_error(f, ret);
- return;
+ return -1;
}
}
+ return 0;
+}
- if (iterable_only) {
- return;
- }
+static void qemu_savevm_section_full(QEMUFile *f)
+{
+ QJSON *vmdesc;
+ int vmdesc_len;
+ SaveStateEntry *se;
+ bool in_postcopy = migration_in_postcopy(migrate_get_current());
vmdesc = qjson_new();
json_prop_int(vmdesc, "page_size", TARGET_PAGE_SIZE);
@@ -1111,6 +1110,26 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f,
bool iterable_only)
qemu_put_buffer(f, (uint8_t *)qjson_get_str(vmdesc), vmdesc_len);
}
object_unref(OBJECT(vmdesc));
+}
+
+void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only)
+{
+ int ret;
+
+ trace_savevm_state_complete_precopy();
+
+ cpu_synchronize_all_states();
+
+ ret = qemu_savevm_section_end(f, iterable_only);
+ if (ret < 0) {
+ return;
+ }
+
+ if (iterable_only) {
+ return;
+ }
+
+ qemu_savevm_section_full(f);
qemu_fflush(f);
}
--
1.8.3.1
- [Qemu-devel] [RFC 11/13] snapshot/migration: Save VM's RAM into snapshot file, (continued)
- [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
- [Qemu-devel] [RFC 06/13] QEMUSizedBuffer: Introduce two help functions for qsb, zhanghailiang, 2016/01/07
- [Qemu-devel] [RFC 07/13] savevm: Split qemu_savevm_state_complete_precopy() into two helper functions,
zhanghailiang <=
- [Qemu-devel] [RFC 12/13] migration/ram: Fix some helper functions' parameter to use PageSearchStatus, zhanghailiang, 2016/01/07