From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YudeI-00028z-A1 for qemu-devel@nongnu.org; Tue, 19 May 2015 05:17:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YudeF-0001Rt-39 for qemu-devel@nongnu.org; Tue, 19 May 2015 05:17:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YudeE-0001Pg-Ro for qemu-devel@nongnu.org; Tue, 19 May 2015 05:17:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4J9HCt6031540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 19 May 2015 05:17:12 -0400 Date: Tue, 19 May 2015 10:17:09 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150519091708.GA2127@work-vm> References: <1431620920-19710-1-git-send-email-quintela@redhat.com> <1431620920-19710-9-git-send-email-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431620920-19710-9-git-send-email-quintela@redhat.com> Subject: Re: [Qemu-devel] [PATCH 8/9] vmstate: Create optional sections List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org * Juan Quintela (quintela@redhat.com) wrote: > To make sections optional, we need to do it at the beggining of the code. > > Signed-off-by: Juan Quintela Do you also need to add this test to qemu_save_device_state ? Dave > --- > 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 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK