[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 8/9] vmstate: Create optional sections
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 8/9] vmstate: Create optional sections |
Date: |
Thu, 14 May 2015 18:28:39 +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 ++
migration/vmstate.c | 11 +++++++++++
savevm.c | 4 ++++
3 files changed, 17 insertions(+)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index fc5e643..a8b59eb 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -813,6 +813,8 @@ int vmstate_load_state(QEMUFile *f, const
VMStateDescription *vmsd,
void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, QJSON *vmdesc);
+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/migration/vmstate.c b/migration/vmstate.c
index 108995e..36dab84 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -276,6 +276,17 @@ static void vmsd_desc_field_end(const VMStateDescription
*vmsd, QJSON *vmdesc,
json_end_object(vmdesc);
}
+
+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, QJSON *vmdesc)
{
diff --git a/savevm.c b/savevm.c
index 01770cd..2b4e554 100644
--- a/savevm.c
+++ b/savevm.c
@@ -763,6 +763,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);
json_start_object(vmdesc, NULL);
--
2.4.0
- [Qemu-devel] [PATCH 4/9] runstate: create runstate_index function, (continued)
- [Qemu-devel] [PATCH 4/9] runstate: create runstate_index function, Juan Quintela, 2015/05/14
- [Qemu-devel] [PATCH 5/9] runstate: migration allows more transitions now, Juan Quintela, 2015/05/14
- [Qemu-devel] [PATCH 1/9] migration: create savevm_state, Juan Quintela, 2015/05/14
- [Qemu-devel] [PATCH 6/9] migration: create new section to store global state, Juan Quintela, 2015/05/14
- [Qemu-devel] [PATCH 7/9] global_state: Make section optional, Juan Quintela, 2015/05/14
- [Qemu-devel] [PATCH 8/9] vmstate: Create optional sections,
Juan Quintela <=
- [Qemu-devel] [PATCH 2/9] migration: Use normal VMStateDescriptions for Subsections, Juan Quintela, 2015/05/14
- [Qemu-devel] [PATCH 9/9] migration: Add configuration section, Juan Quintela, 2015/05/14