[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 14/18] rtc: add a dynamic property for retrievin
From: |
Gerd Hoffmann |
Subject: |
Re: [Qemu-devel] [PATCH 14/18] rtc: add a dynamic property for retrieving the date |
Date: |
Thu, 01 Dec 2011 16:46:33 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111104 Red Hat/3.1.16-2.el6_1 Thunderbird/3.1.16 |
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);
[ ... ]
);
... 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.
cheers,
Gerd
- Re: [Qemu-devel] [PATCH 14/18] rtc: add a dynamic property for retrieving the date,
Gerd Hoffmann <=