qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] migration: split qemu_loadvm_section_start_full


From: Li Zhijian
Subject: [Qemu-devel] [PATCH 1/2] migration: split qemu_loadvm_section_start_full() to qemu_loadvm_section_{start(), full()}
Date: Thu, 29 Sep 2016 19:06:31 +0800

Signed-off-by: Li Zhijian <address@hidden>
---
 migration/savevm.c | 53 +++++++++++++++++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 18 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 33a2911..09d8e99 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1729,48 +1729,65 @@ void loadvm_free_handlers(MigrationIncomingState *mis)
     }
 }
 
+
 static int
-qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis)
+qemu_loadvm_section_start(QEMUFile *f, MigrationIncomingState *mis,
+                          SaveStateEntry **se,
+                          uint32_t *version_id, uint32_t *section_id)
 {
-    uint32_t instance_id, version_id, section_id;
-    SaveStateEntry *se;
-    LoadStateEntry *le;
+    uint32_t instance_id;
     char idstr[256];
-    int ret;
 
     /* Read section start */
-    section_id = qemu_get_be32(f);
+    *section_id = qemu_get_be32(f);
     if (!qemu_get_counted_string(f, idstr)) {
         error_report("Unable to read ID string for section %u",
-                     section_id);
+                     *section_id);
         return -EINVAL;
     }
     instance_id = qemu_get_be32(f);
-    version_id = qemu_get_be32(f);
+    *version_id = qemu_get_be32(f);
 
-    trace_qemu_loadvm_state_section_startfull(section_id, idstr,
-            instance_id, version_id);
+    trace_qemu_loadvm_state_section_startfull(*section_id, idstr,
+            instance_id, *version_id);
     /* Find savevm section */
-    se = find_se(idstr, instance_id);
-    if (se == NULL) {
+    *se = find_se(idstr, instance_id);
+    if (*se == NULL) {
         error_report("Unknown savevm section or instance '%s' %d",
                      idstr, instance_id);
         return -EINVAL;
     }
 
     /* Validate version */
-    if (version_id > se->version_id) {
+    if (*version_id > (*se)->version_id) {
         error_report("savevm: unsupported version %d for '%s' v%d",
-                     version_id, idstr, se->version_id);
+                     *version_id, idstr, (*se)->version_id);
         return -EINVAL;
     }
 
     /* Validate if it is a device's state */
-    if (xen_enabled() && se->is_ram) {
+    if (xen_enabled() && (*se)->is_ram) {
         error_report("loadvm: %s RAM loading not allowed on Xen", idstr);
         return -EINVAL;
     }
 
+    return 0;
+}
+
+static int
+qemu_loadvm_section_full(QEMUFile *f, MigrationIncomingState *mis)
+{
+    uint32_t version_id, section_id;
+    SaveStateEntry *se;
+    LoadStateEntry *le;
+    char idstr[256];
+    int ret;
+
+    ret = qemu_loadvm_section_start(f, mis, &se, &version_id, &section_id);
+    if (ret) {
+        return ret;
+    }
+
     /* Add entry */
     le = g_malloc0(sizeof(*le));
 
@@ -1781,8 +1798,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, 
MigrationIncomingState *mis)
 
     ret = vmstate_load(f, le->se, le->version_id);
     if (ret < 0) {
-        error_report("error while loading state for instance 0x%x of"
-                     " device '%s'", instance_id, idstr);
+        error_report("error while loading state for"
+                     " device '%s'", idstr);
         return ret;
     }
     if (!check_section_footer(f, le)) {
@@ -1836,7 +1853,7 @@ static int qemu_loadvm_state_main(QEMUFile *f, 
MigrationIncomingState *mis)
         switch (section_type) {
         case QEMU_VM_SECTION_START:
         case QEMU_VM_SECTION_FULL:
-            ret = qemu_loadvm_section_start_full(f, mis);
+            ret = qemu_loadvm_section_full(f, mis);
             if (ret < 0) {
                 return ret;
             }
-- 
2.7.4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]