From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbuXC-0008Oy-5P for qemu-devel@nongnu.org; Tue, 05 Jun 2012 10:15:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SbuX5-0005r0-U2 for qemu-devel@nongnu.org; Tue, 05 Jun 2012 10:14:57 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:48748) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbuX5-0005qn-L7 for qemu-devel@nongnu.org; Tue, 05 Jun 2012 10:14:51 -0400 Received: by dadv2 with SMTP id v2so7957545dad.4 for ; Tue, 05 Jun 2012 07:14:49 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FCE1454.9040604@redhat.com> Date: Tue, 05 Jun 2012 16:14:44 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1338858018-17189-1-git-send-email-mdroth@linux.vnet.ibm.com> <1338858018-17189-13-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1338858018-17189-13-git-send-email-mdroth@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 12/17] rtc: add a QOM property for accessing device state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: aliguori@us.ibm.com, yamahata@valinux.co.jp, quintela@redhat.com, qemu-devel@nongnu.org, owasserm@redhat.com, akong@redhat.com, afaerber@suse.de Il 05/06/2012 03:00, Michael Roth ha scritto: > This will eventually be used to serialize device state for the purposes > of migration/savevm, and is also useful for introspection/testing. > > Signed-off-by: Michael Roth > --- > hw/mc146818rtc.c | 12 ++++++++++++ > 1 files changed, 12 insertions(+), 0 deletions(-) > > diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c > index 7490d28..2dfc233 100644 > --- a/hw/mc146818rtc.c > +++ b/hw/mc146818rtc.c > @@ -26,6 +26,7 @@ > #include "sysemu.h" > #include "mc146818rtc.h" > #include "mc146818rtc_state.h" > +#include "qapi-generated/mc146818rtc-qapi-visit.h" > > #ifdef TARGET_I386 > #include "apic.h" > @@ -590,6 +591,14 @@ static void rtc_get_date(Object *obj, Visitor *v, void *opaque, > visit_end_struct(v, errp); > } > > +static void rtc_get_state(Object *obj, Visitor *v, void *opaque, > + const char *name, Error **errp) > +{ > + ISADevice *isa = ISA_DEVICE(obj); > + RTCState *s = DO_UPCAST(RTCState, dev, isa); > + visit_type_RTCState(v, &s, name, errp); > +} > + > static int rtc_initfn(ISADevice *dev) > { > RTCState *s = DO_UPCAST(RTCState, dev, dev); > @@ -638,6 +647,9 @@ static int rtc_initfn(ISADevice *dev) > object_property_add(OBJECT(s), "date", "struct tm", > rtc_get_date, NULL, NULL, s, NULL); > > + object_property_add(OBJECT(s), "state", "RTCState", > + rtc_get_state, NULL, NULL, s, NULL); > + > return 0; > } > Nice! The next obvious step would be to use this from vmstate instead of hardcoded struct offsets. Paolo