From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792502754; b=x2gBoLTRTRzq+JSixXpyPOgPc//K31rNd0QtctqtHAQyZIMln7X0AUGgG65WF6cUKI8Z S6JCkBCMZb5Purg9mucFATWPaH0SP5/qWVw/q276fYZ+QBUYtxe9oGxMFNVYVg8AjjhDg di5QrEjifgYK6KOt4BVEfHj1yqGK/rGdwosDbzPWw0YctO2SX7Q8OanaCmuGFFOWrL4z9 GqIejCyJuWifLht+L3VPiSsJTH7+b8isQ7D4MVVto06H2+CMq66ynb+uQ01XxtEtI9OeU Wwsf+P2GHBEykd6LD8pCF/fN2gLpSopg+NC8Di1DxCIXO3AB5jI0x+xCNOs88UeBirQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792502754; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Received:From:To:Cc:Subject: In-Reply-To:References:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:X-Scanned-By; bh=iZCI3o0wJlVAfnoZvSx8CT5djmTykiJdbItsauKw+V8=; b=LFeXYKZhTXHhXSkO0o8XVPz5BXImCnTmmYG8HMIQxom9dgnKcEWq6pcEk79VBX2s5VgW Wq8F1a3HUjezwff3lcIbw13B4JK3pGLfEtGaOB5lW38Tcy2y1uiYXy40K8wkNY3FX4Pa6 /1kTT65i5xqYkTUkQk18Ow2V0mcDPFGXQ+6ZYjZFEKGYO19w3fsVTWK8YwagCv2zRf8yw kMmNYDvKwE0V+n/CiwAx1wBVJxlDgBaVX6sNk16A0iXkG76LR4ZHWkOWG51Dy6PKALIr0 hl/yzqpWQseWBjAShPen0C23g97FovcPDuvy/QZwbJNfmRaAbLv4jnJRclrcu9h6y/Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BDtHK845; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AED5606A319 for ; Tue, 20 Oct 2026 13:25:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6AED5606A319 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BDtHK845 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792502752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iZCI3o0wJlVAfnoZvSx8CT5djmTykiJdbItsauKw+V8=; b=BDtHK845o4/kqhelySR0etd3RJTNtPq1NXWvxYOR/pcpSFiQr/jVEYztM5+zJz8wC4T2dQ 666YWnVU32nxT5GA+PZJWQaIiK87GaLOn+NwfJojdK3dXOk8XfGFQE3CaR1SoG2s3SDTml Zti4LupLxMfywRen9En7zZLjcE49Wew= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-402-GpgImfhOMWa0lumUFG9c1g-1; Tue, 20 Oct 2026 13:25:47 +0000 X-MC-Unique: GpgImfhOMWa0lumUFG9c1g-1 X-Mimecast-MFC-AGG-ID: GpgImfhOMWa0lumUFG9c1g_1792502743 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D737F1800BDD; Tue, 20 Oct 2026 13:25:39 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.5]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA9B818005B3; Tue, 20 Oct 2026 13:25:35 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 71D8121E6A04; Tue, 20 Oct 2026 15:25:33 +0200 (CEST) From: Markus Armbruster To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org, Michael Roth , John Snow , Peter Maydell , Mauro Carvalho Chehab , Pierrick Bouvier , Paolo Bonzini , Daniel P. =?utf-8?Q?Berrang=C3=A9?= , Kostiantyn Kostiuk , Eric Blake , David Hildenbrand , Igor Mammedov , "Edgar E. Iglesias" , Jason Wang , Marcelo Tosatti , kvm@vger.kernel.org, Alberto Garcia , Kevin Wolf , Hanna Reitz , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Zhao Liu , Jonathan Cameron , Junjie Cao , Anisa Su , Elena Ufimtseva , Jagannathan Raman , John Levon , Thanos Makatos , =?utf-8?Q?C=C3=A9dric?= Le Goater , Cornelia Huck , Eric Farman , Matthew Rosato , Richard Henderson , Ilya Leoshkevich , qemu-block@nongnu.org, linux-cxl@vger.kernel.org, qemu-s390x@nongnu.org, "Michael S. Tsirkin" , Sergio Lopez , qemu-arm@nongnu.org, Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , qemu-riscv@nongnu.org, Song Gao <17746591750@163.com>, Bibo Mao , Xianglai Li , Jiaxun Yang , Pedro Barbuda , Mohamed Mediouni , Nicholas Piggin , Harsh Prateek Bora , Amit Machhiwal , qemu-ppc@nongnu.org, Zhang Chen , Li Zhijian , Alistair Francis , Alexander Graf , "Gonglei (Arei)" , zhenwei pi , Ani Sinha , Luc Michel , =?utf-8?Q?C=C3=A9dric?= Le Goater , Jamin Lin , Kane Chen , Samuel Tardieu , "Denis V. Lunev" , FangSheng Huang , Tyrone Ting , Hao Wu , Keith Busch , Klaus Jensen , Jesper Devantier , Aditya Gupta , Glenn Miles , Conor Dooley , Sebastian Huber , Halil Pasic , Christian Borntraeger , Jason Herne , Titus Rwantare , Stefano Stabellini , Anthony PERARD , Peter Xu , Chinmay Rath , Hendrik Brueckner , xen-devel@lists.xenproject.org, Roman Bolshakov , Phil Dennis-Jordan , Fam Zheng , Farhan Ali , Alex Williamson , Tao Tang , Stefan Berger , Fabiano Rosas , Mark Cave-Ayland , Artyom Tarasenko , Yoshinori Sato , Jiri Pirko , Eric Auger , Laurent Vivier Subject: Re: [PATCH v7 43/65] qom: replace object_property_add_tm with StructTm QAPI type In-Reply-To: <20261020-qom-qapi-v7-43-431a86b02b58@redhat.com> (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Tue, 20 Oct 2026 14:46:00 +0400") References: <20261020-qom-qapi-v7-0-431a86b02b58@redhat.com> <20261020-qom-qapi-v7-43-431a86b02b58@redhat.com> Date: Tue, 20 Oct 2026 15:25:33 +0200 Message-ID: <874iegpkqa.fsf@pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Marc-Andr=C3=A9 Lureau writes: > 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. > > Reviewed-by: Amit Machhiwal > Signed-off-by: Markus Armbruster > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > hw/ppc/spapr_rtc.c | 24 +++++++++++++++--- > hw/rtc/mc146818rtc.c | 22 ++++++++++++++--- > include/qom/object.h | 29 ---------------------- > qapi/common.json | 28 +++++++++++++++++++++ > qapi/pragma.json | 1 + > qom/object.c | 69 ----------------------------------------------= ------ > 6 files changed, 69 insertions(+), 104 deletions(-) > > diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c > index 1f7d2d8f898b..5105cf538f64 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" >=20=20 > @@ -131,9 +134,23 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, Sp= aprMachineState *spapr, > rtas_st(rets, 0, RTAS_OUT_SUCCESS); > } >=20=20 > -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 =3D &tm; > + > + spapr_rtc_read(SPAPR_RTC(obj), &value, NULL); > + > + tm =3D (StructTm) { > + .tm_year =3D value.tm_year, > + .tm_mon =3D value.tm_mon, > + .tm_mday =3D value.tm_mday, > + .tm_hour =3D value.tm_hour, > + .tm_min =3D value.tm_min, > + .tm_sec =3D value.tm_sec, > + }; > + visit_type_StructTm(v, name, &tmp, errp); > } >=20=20 > static void spapr_rtc_realize(DeviceState *dev, Error **errp) > @@ -150,7 +167,8 @@ static void spapr_rtc_realize(DeviceState *dev, Error= **errp) > rtc_ns =3D qemu_clock_get_ns(rtc_clock); > rtc->ns_offset =3D host_s * NANOSECONDS_PER_SECOND - rtc_ns; >=20=20 > - object_property_add_tm(OBJECT(rtc), "date", spapr_rtc_qom_date); > + object_property_add_qapi(OBJECT(rtc), "date", &StructTm_type_info, > + spapr_rtc_qom_date, NULL, NULL, NULL); The @type reported by qom-list & friends changes from "struct tm" (visible at the end of this patch) to to "StuctTm". Such changes can be compatibility breaks. Same "this is okay" argument as for the previous patch, and same request: please note the change in the commit message. > } >=20=20 > static const VMStateDescription vmstate_spapr_rtc =3D { > diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c > index ba396435d1af..6010f8587ce0 100644 > --- a/hw/rtc/mc146818rtc.c > +++ b/hw/rtc/mc146818rtc.c > @@ -42,6 +42,8 @@ > #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 "trace.h" >=20=20 > @@ -854,12 +856,25 @@ static const MemoryRegionOps cmos_ops =3D { > .endianness =3D DEVICE_LITTLE_ENDIAN, > }; >=20=20 > -static void rtc_get_date(Object *obj, struct tm *current_tm, Error **err= p) > +static void rtc_get_date(Object *obj, Visitor *v, const char *name, > + void *opaque, Error **errp) > { > MC146818RtcState *s =3D MC146818_RTC(obj); > + struct tm value; > + StructTm tm, *tmp =3D &tm; >=20=20 > rtc_update_time(s); > - rtc_get_time(s, current_tm); > + rtc_get_time(s, &value); > + > + tm =3D (StructTm) { > + .tm_year =3D value.tm_year, > + .tm_mon =3D value.tm_mon, > + .tm_mday =3D value.tm_mday, > + .tm_hour =3D value.tm_hour, > + .tm_min =3D value.tm_min, > + .tm_sec =3D value.tm_sec, > + }; > + visit_type_StructTm(v, name, &tmp, errp); > } >=20=20 > static void rtc_realizefn(DeviceState *dev, Error **errp) > @@ -1019,7 +1034,8 @@ static void rtc_class_initfn(ObjectClass *klass, co= nst void *data) > device_class_set_props(dc, mc146818rtc_properties); > set_bit(DEVICE_CATEGORY_MISC, dc->categories); >=20=20 > - object_class_property_add_tm(klass, "date", rtc_get_date); > + object_class_property_add_qapi(klass, "date", &StructTm_type_info, > + rtc_get_date, NULL, NULL, NULL); > } >=20=20 > static const TypeInfo mc146818rtc_info =3D { > diff --git a/include/qom/object.h b/include/qom/object.h > index e04be4caed57..29cbd84b8d03 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -2156,35 +2156,6 @@ object_class_property_add_qapi(ObjectClass *klass, > ObjectPropertyRelease *release, > void *opaque); >=20=20 > -/** > - * object_property_add_tm: > - * @obj: the object to add a property to > - * @name: the name of the property > - * @get: the getter or NULL if the property is write-only. > - * > - * Add a read-only struct tm valued property using a getter function. > - * This function will add a property of type 'struct tm'. > - * > - * Returns: The newly added property on success, or %NULL on failure. > - */ > -ObjectProperty *object_property_add_tm(Object *obj, const char *name, > - void (*get)(Object *, struct tm *, Error **)= ); > - > -/** > - * object_class_property_add_tm: > - * @klass: the object class to add a property to > - * @name: the name of the property > - * @get: the getter or NULL if the property is write-only. > - * > - * Add a read-only struct tm valued property using a getter function. > - * This function will add a property of type 'struct tm'. > - * > - * Returns: The newly added property on success, or %NULL on failure. > - */ > -ObjectProperty *object_class_property_add_tm(ObjectClass *klass, > - const char *name, > - void (*get)(Object *, struct tm *, Error **)= ); > - > typedef enum { > /* Automatically add a getter to the property */ > OBJ_PROP_FLAG_READ =3D 1 << 0, > diff --git a/qapi/common.json b/qapi/common.json > index 1352e664b23e..222037ea0b32 100644 > --- a/qapi/common.json > +++ b/qapi/common.json > @@ -218,3 +218,31 @@ > ## > { 'enum': 'EndianMode', > 'data': [ 'unspecified', 'little', 'big' ] } > + > +## > +# @StructTm: > +# > +# Broken-down time. Field semantics match C ``struct tm``. Again, please use the revised syntax for introductions. > +# > +# @tm_year: years since 1900 > +# > +# @tm_mon: months since January (0-11) > +# > +# @tm_mday: day of the month (1-31) > +# > +# @tm_hour: hours since midnight (0-23) > +# > +# @tm_min: minutes after the hour (0-59) > +# > +# @tm_sec: seconds after the minute (0-59, 60-61 for leap seconds) > +# > +# Since: 11.2 Same "do we care?" as for the previous patch. > +## > +{ 'struct': 'StructTm', > + 'data': { > + 'tm_year': 'int32', > + 'tm_mon': 'int32', > + 'tm_mday': 'int32', > + 'tm_hour': 'int32', > + 'tm_min': 'int32', > + 'tm_sec': 'int32' } } > diff --git a/qapi/pragma.json b/qapi/pragma.json > index 342cedc42e76..9be2819a46bd 100644 > --- a/qapi/pragma.json > +++ b/qapi/pragma.json > @@ -109,6 +109,7 @@ # Externally visible types whose member names may use uppercase Not this patch's fault, but here goes anyway: the comment should be "may use uppercase or '_'". I'll fix it. 'member-name-exceptions': [ # visible in: 'ACPISlotType', # query-acpi-ospm-status [...] > 'QKeyCode', # send-key, input-sent-event > 'QapiErrorClass', # QMP error replies > 'SshHostKeyCheckMode', # blockdev-add, -blockdev > + 'StructTm', # qom-get of RTC date property > 'SysEmuTarget', # query-cpu-fast, query-target > 'UuidInfo', # query-uuid > 'VncClientInfo', # query-vnc, query-vnc-servers, ... [...]