From df8961522a3d6bc7bb60c2830ef59e7c6c67a928 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Wed, 15 Oct 2014 09:39:14 +0200 Subject: vmstate: Create optional sections To make sections optional, we need to do it at the beggining of the code. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/vmstate.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'migration/vmstate.c') diff --git a/migration/vmstate.c b/migration/vmstate.c index 6138d1acb7..e8ccf22f67 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) { -- cgit v1.2.1