> Define a StructTm QAPI struct in common.json matching the existing > "struct tm" property wire format (tm_year, tm_mon, tm_mday, tm_hour, > tm_min, tm_sec as int32). > > Convert the two callers (mc146818rtc and spapr_rtc) to use > object_property_add_qapi() with a standard ObjectPropertyAccessor > that populates a StructTm and calls the generated visitor. > > Remove object_property_add_tm(), object_class_property_add_tm(), > the TMProperty type, and the property_get_tm() helper from > qom/object.c, along with their declarations in object.h. > > Signed-off-by: Marc-André Lureau <[email protected]> > Reviewed-by: Amit Machhiwal <[email protected]> > Signed-off-by: Markus Armbruster <[email protected]> > Message-ID: <[email protected]> > --- > qapi/common.json | 28 ++++++++++++++++++ > qapi/pragma.json | 1 + > include/qom/object.h | 29 ------------------- > hw/ppc/spapr_rtc.c | 18 ++++++++++-- > hw/rtc/mc146818rtc.c | 16 ++++++++-- > qom/object.c | 69 -------------------------------------------- > 6 files changed, 57 insertions(+), 104 deletions(-) > > diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c > index 1f7d2d8f898b..a4a2b3237e26 100644 > --- a/hw/ppc/spapr_rtc.c > +++ b/hw/ppc/spapr_rtc.c > @@ -33,6 +33,9 @@ > #include "migration/vmstate.h" > #include "qapi/error.h" > #include "qapi/qapi-events-misc.h" > +#include "qapi/qapi-type-infos-common.h" > +#include "qapi/qapi-visit-common.h" > +#include "qapi/visitor.h" > #include "qemu/cutils.h" > #include "qemu/module.h" > > @@ -131,9 +134,17 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, > SpaprMachineState *spapr, > rtas_st(rets, 0, RTAS_OUT_SUCCESS); > } > > -static void spapr_rtc_qom_date(Object *obj, struct tm *current_tm, Error > **errp) > +static void spapr_rtc_qom_date(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > { > - spapr_rtc_read(SPAPR_RTC(obj), current_tm, NULL); > + struct tm value; > + StructTm tm, *tmp = &tm; > + > + spapr_rtc_read(SPAPR_RTC(obj), &value, NULL); > + > + tm = (StructTm) { value.tm_year, value.tm_mon, value.tm_mday,
Positional initialization relies on the QAPI field order matching the struct tm field order here (and in mc146818rtc.c). Designated initializers (.tm_year = value.tm_year, ...) would be robust against a future reordering of either side. -- Marc-André Lureau <[email protected]>
