qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 7/7] vmstate: Create optional sections


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 7/7] vmstate: Create optional sections
Date: Wed, 15 Oct 2014 09:55:10 +0200

To make sections optional, we need to do it at the beggining of the code.

Signed-off-by: Juan Quintela <address@hidden>
---
 include/migration/vmstate.h |  2 ++
 savevm.c                    |  4 ++++
 vmstate.c                   | 11 +++++++++++
 3 files changed, 17 insertions(+)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 3556924..a5155be 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -766,6 +766,8 @@ int vmstate_load_state(QEMUFile *f, const 
VMStateDescription *vmsd,
 void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                         void *opaque);

+bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque);
+
 int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
                                    const VMStateDescription *vmsd,
                                    void *base, int alias_id,
diff --git a/savevm.c b/savevm.c
index eed43e6..3884e0b 100644
--- a/savevm.c
+++ b/savevm.c
@@ -727,6 +727,10 @@ void qemu_savevm_state_complete(QEMUFile *f)
         if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
             continue;
         }
+        if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) {
+            continue;
+        }
+
         trace_savevm_section_start(se->idstr, se->section_id);
         /* Section type */
         qemu_put_byte(f, QEMU_VM_SECTION_FULL);
diff --git a/vmstate.c b/vmstate.c
index bb02b7d..b8914ac 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -131,6 +131,17 @@ int vmstate_load_state(QEMUFile *f, const 
VMStateDescription *vmsd,
     return 0;
 }

+
+bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque)
+{
+    if (vmsd->needed && !vmsd->needed(opaque)) {
+        /* optional section not needed */
+        return false;
+    }
+    return true;
+}
+
+
 void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                         void *opaque)
 {
-- 
2.1.0




reply via email to

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