From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWHmk-0002my-LV for qemu-devel@nongnu.org; Thu, 01 Dec 2011 20:19:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWHmi-0005en-Fj for qemu-devel@nongnu.org; Thu, 01 Dec 2011 20:19:30 -0500 Received: from mail-gy0-f173.google.com ([209.85.160.173]:62278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWHmi-0005eb-DJ for qemu-devel@nongnu.org; Thu, 01 Dec 2011 20:19:28 -0500 Received: by ghbg19 with SMTP id g19so3159757ghb.4 for ; Thu, 01 Dec 2011 17:19:28 -0800 (PST) Message-ID: <4ED82799.20806@codemonkey.ws> Date: Thu, 01 Dec 2011 19:19:21 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1322687028-29714-1-git-send-email-aliguori@us.ibm.com> <1322687028-29714-15-git-send-email-aliguori@us.ibm.com> <4ED7A159.20902@redhat.com> In-Reply-To: <4ED7A159.20902@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 14/18] rtc: add a dynamic property for retrieving the date List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi , Jan Kiszka , qemu-devel@nongnu.org, Markus Armbruster , Luiz Capitulino On 12/01/2011 09:46 AM, Gerd Hoffmann wrote: > Hi, > >> +static void rtc_get_date(DeviceState *dev, Visitor *v, void *opaque, >> + const char *name, Error **errp) >> +{ >> + ISADevice *isa = DO_UPCAST(ISADevice, qdev, dev); >> + RTCState *s = DO_UPCAST(RTCState, dev, isa); >> + >> + visit_start_struct(v, NULL, "struct tm", name, 0, errp); >> + visit_type_int32(v,&s->current_tm.tm_year, "tm_year", errp); >> + visit_type_int32(v,&s->current_tm.tm_mon, "tm_mon", errp); >> + visit_type_int32(v,&s->current_tm.tm_mday, "tm_mday", errp); >> + visit_type_int32(v,&s->current_tm.tm_hour, "tm_hour", errp); >> + visit_type_int32(v,&s->current_tm.tm_min, "tm_min", errp); >> + visit_type_int32(v,&s->current_tm.tm_sec, "tm_sec", errp); >> + visit_end_struct(v, errp); >> +} > > Ok, what is the long term plan here? I don't think we want open-code > everything here, do we? Especially once visitors become more widespread > used. And I can see that they are useful for a bunch of stuff beside > device properties and relationships. vmstate for example. Or to list > device state (say a register dump) for debugging purposes. > > Today we have code to generate structs and visitors from scratch. > I think it would be useful to also generate visitors for existing > structs, with some kind of annotation, like this ... > > struct SomeDev { > DeviceState dev; > Chardev *chr; > uint32_t reg1 __v(vmstate); > uint32_t reg2 __v(vmstate); > [ ... ] > ); https://github.com/aliguori/qidl/ In your example: struct SomeDev { DeviceState _immutable dev; Chardev _immutable *chr; uint32_t reg1; uint32_t reg2; [ ... ] }; > > ... instead of the vmstate structs we create manually today. Likewise > for properties. And probably we can even generate different visitors > for different "views" at the same struct. qc generates a json description of the struct. You can then use a generate to take that json and generate code for VMState, QAPI, etc. The readme has quite a lot of detail about the syntax. The parser is pretty complete already. https://github.com/aliguori/qidl/blob/master/qc.md But I want to get us moving on QOM first before I go any further with this. We can always go back and remove the manually written visit functions. Regards, Anthony Liguori > > cheers, > Gerd >