Patchwork vmstate: fix vmstate_load_state for subsections

login
register
mail settings
Submitter TeLeMan
Date Aug. 10, 2010, 9:22 a.m.
Message ID <AANLkTi=P+7C8Opc5gzmybvp6xK4TZbohN9rMVs_0m+Vg@mail.gmail.com>
Download mbox | patch
Permalink /patch/61366/
State New
Headers show

Comments

TeLeMan - Aug. 10, 2010, 9:22 a.m.
If one vmstate includes subsections and its last field flag is
VMS_STRUCT, vmstate_load_state will be always failed when the
subsections exist. This fix is not perfect because if the last field
includes subsections too, vmstate_load_state will maybe be failed when
not all of the subsections exist. I think vmstate subsections needs to
be redesigned.

Signed-off-by: TeLeMan <geleman@gmail.com>
---
 savevm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

         return vmsd->post_load(opaque, version_id);

Patch

diff --git a/savevm.c b/savevm.c
index 2082b8c..feca8fa 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1286,9 +1286,11 @@  int vmstate_load_state(QEMUFile *f, const
VMStateDescription *vmsd,
         }
         field++;
     }
-    ret = vmstate_subsection_load(f, vmsd, opaque);
-    if (ret != 0) {
-        return ret;
+    if (vmsd->subsections) {
+        ret = vmstate_subsection_load(f, vmsd, opaque);
+        if (ret != 0) {
+            return ret;
+        }
     }
     if (vmsd->post_load) {