qapi: Move RTC_CHANGE back out of target schema
v2 cover qapi: Move RTC_CHANGE back out of target schema
This patchset moves RTC_CHANGE back to misc.json, effectively reverting commit 183e4281a30962, which moved the RTC_CHANGE event to the target schema. That change was an attempt to make the event target-specific to improve introspection, but the event isn't really
target-specific: it's machine or device specific. Putting RTC_CHANGE in the target schema with an ifdef list reduces maintainability (by adding an if: list with a long list of targets that needs to be manually updated as architectures are added or removed or as new devices gain the RTC_CHANGE functionality) and increases compile time (by preventing RTC devices which emit the event from being "compile once" rather than "compile once per target", because qapi-events-misc-target.h uses TARGET_* ifdefs, which are poisoned in "compile once" files.)
Patch 2 fixes some minor documentation issues for the RTC_CHANGE event, noticed during development of the patchset.
Patch 3 makes the pl031 a build-once file again, which was the initial motivation for the series.
Changes v1->v2:
* patch 1 needs to change the #include line for pl031.c, now that the change to make that device emit RTC_CHANGE has landed upstream
* patch 2 now also notes in the RTC_CHANGE documentation that not all devices/systems will emit the event (suggested by Markus)
* patch 3 is new
My default assumption is that this series will go in via the qapi tree; let me know if you'd prefer me to take it via target-arm instead.
thanks
-- PMM
Peter Maydell (3):
qapi: Move RTC_CHANGE back out of target schema
qapi: Document some missing details of RTC_CHANGE event hw/rtc: Compile pl031 once-only
qapi/misc-target.json | 33 --------------------------------- qapi/misc.json | 24 ++++++++++++++++++++++++ hw/ppc/spapr_rtc.c | 2 +- hw/rtc/mc146818rtc.c | 2 +- hw/rtc/pl031.c | 2 +- hw/rtc/meson.build | 2 +- 6 files changed, 28 insertions(+), 37 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/3 qapi: Move RTC_CHANGE back out of target schema
This commit effectively reverts commit 183e4281a30962, which moved the RTC_CHANGE event to the target schema. That change was an attempt to make the event target-specific to improve introspection, but the event isn't really target-specific: it's machine or device specific. Putting RTC_CHANGE in the target schema with an ifdef list reduces maintainability (by adding an if: list with a long list of targets that needs to be manually updated as architectures are added or removed or as new devices gain the RTC_CHANGE functionality) and increases compile time (by preventing RTC devices which emit the event from being "compile once" rather than "compile once per target", because qapi-events-misc-target.h uses TARGET_* ifdefs, which are poisoned in "compile once" files.)
Move RTC_CHANGE back to misc.json.
--- qapi/misc-target.json | 33 --------------------------------- qapi/misc.json | 22 ++++++++++++++++++++++ hw/ppc/spapr_rtc.c | 2 +- hw/rtc/mc146818rtc.c | 2 +- hw/rtc/pl031.c | 2 +- 5 files changed, 25 insertions(+), 36 deletions(-)
qapi/misc-target.json +0 -33
@@ -2,39 +2,6 @@ # vim: filetype=python # -## -# @RTC_CHANGE: -# -# Emitted when the guest changes the RTC time. -# -# @offset: offset between base RTC clock (as specified by -rtc base), and -# new RTC clock value -# -# Note: This event is rate-limited. -# -# Since: 0.13 -# -# Example: -# -# <- { "event": "RTC_CHANGE", -# "data": { "offset": 78 }, -# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } -# -## -{ 'event': 'RTC_CHANGE', - 'data': { 'offset': 'int' }, - 'if': { 'any': [ 'TARGET_ALPHA', - 'TARGET_ARM', - 'TARGET_HPPA', - 'TARGET_I386', - 'TARGET_MIPS', - 'TARGET_MIPS64', - 'TARGET_PPC', - 'TARGET_PPC64', - 'TARGET_S390X', - 'TARGET_SH4', - 'TARGET_SPARC' ] } } - ## # @rtc-reset-reinjection: #
qapi/misc.json +22 -0
@@ -527,3 +527,25 @@ 'data': { '*option': 'str' }, 'returns': ['CommandLineOptionInfo'], 'allow-preconfig': true } + +## +# @RTC_CHANGE: +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Note: This event is rate-limited. +# +# Since: 0.13 +# +# Example: +# +# <- { "event": "RTC_CHANGE", +# "data": { "offset": 78 }, +# "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } +# +## +{ 'event': 'RTC_CHANGE', + 'data': { 'offset': 'int' } }
hw/ppc/spapr_rtc.c +1 -1
@@ -32,7 +32,7 @@#include "hw/ppc/spapr.h" #include "migration/vmstate.h" #include "qapi/error.h" -#include "qapi/qapi-events-misc-target.h" +#include "qapi/qapi-events-misc.h" #include "qemu/cutils.h" #include "qemu/module.h"
hw/rtc/mc146818rtc.c +1 -1
@@ -40,7 +40,7 @@#include "hw/rtc/mc146818rtc_regs.h" #include "migration/vmstate.h" #include "qapi/error.h" -#include "qapi/qapi-events-misc-target.h" +#include "qapi/qapi-events-misc.h" #include "qapi/visitor.h" #include "hw/rtc/mc146818rtc_regs.h"
hw/rtc/pl031.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/log.h" #include "qemu/module.h" #include "trace.h" -#include "qapi/qapi-events-misc-target.h" +#include "qapi/qapi-events-misc.h" #define RTC_DR 0x00/* Data read register */ #define RTC_MR 0x04/* Match register */
Signature · 1 line
2.25.1
Quoted 18 lines · Peter Maydell
This commit effectively reverts commit
183e4281a30962, which moved theRTC_CHANGEevent to the target schema. That change was an attempt to make the event target-specific to improve introspection, but the event isn't really target-specific: it's machine or device specific. PuttingRTC_CHANGEin the target schema with an ifdef list reduces maintainability (by adding an if: list with a long list of targets that needs to be manually updated as architectures are added or removed or as new devices gain theRTC_CHANGEfunctionality) and increases compile time (by preventing RTC devices which emit the event from being "compile once" rather than "compile once per target", becauseqapi-events-misc-target.huses TARGET_* ifdefs, which are poisoned in "compile once" files.)Move
RTC_CHANGEback to misc.json.Signed-off-by Peter Maydell <[email protected]>Reviewed-by Markus Armbruster <[email protected]>Acked-by Greg Kurz <[email protected]>
Quoted 7 lines
--- qapi/misc-target.json | 33 --------------------------------- qapi/misc.json | 22 ++++++++++++++++++++++ hw/ppc/spapr_rtc.c | 2 +- hw/rtc/mc146818rtc.c | 2 +- hw/rtc/pl031.c | 2 +- 5 files changed, 25 insertions(+), 36 deletions(-)
PATCH v2 2/3 qapi: Document some missing details of RTC_CHANGE event
In reply to Peter MaydellThe RTC_CHANGE event's documentation is missing some details:
* the offset argument is in units of seconds
* it isn't guaranteed that the RTC will implement the event
---v1->v2: add the "RTC might not implement this" note
--- qapi/misc.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
qapi/misc.json +4 -2
@@ -533,10 +533,12 @@ # # Emitted when the guest changes the RTC time. # -# @offset: offset between base RTC clock (as specified by -rtc base), and -# new RTC clock value +# @offset: offset in seconds between base RTC clock (as specified +# by -rtc base), and new RTC clock value # # Note: This event is rate-limited. +# It is not guaranteed that the RTC in the system implements +# this event, or even that the system has an RTC at all. # # Since: 0.13 #
Signature · 1 line
2.25.1
Re: [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event
Quoted 10 lines · Peter Maydell
The
RTC_CHANGEevent's documentation is missing some details:
* the offset argument is in units of seconds
* it isn't guaranteed that the RTC will implement the eventSigned-off-by Peter Maydell <[email protected]>---
v1->v2: add the "RTC might not implement this" note--- qapi/misc.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Re: [PATCH v2 2/3] qapi: Document some missing details of RTC_CHANGE event
In reply to Peter MaydellQuoted 20 lines · Peter Maydell
The
RTC_CHANGEevent's documentation is missing some details:
* the offset argument is in units of seconds
* it isn't guaranteed that the RTC will implement the eventSigned-off-by Peter Maydell <[email protected]>---
v1->v2: add the "RTC might not implement this" note--- qapi/misc.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)qapi/misc.json +0
-1@@ -533,10 +533,12 @@ # # Emitted when the guest changes the RTC time. # -# @offset: offset between base RTC clock (as specified by -rtc base), and
qapi/misc.json line 544
Quoted 10 lines
qapi/misc.json +4
-1-# new RTC clock value +# @offset: offset in seconds between base RTC clock (as specified +# by -rtc base), and new RTC clock value # # Note: This event is rate-limited. +# It is not guaranteed that the RTC in the system implements +# this event, or even that the system has an RTC at all. # # Since: 0.13 #
PATCH v2 3/3 hw/rtc: Compile pl031 once-only
In reply to Peter MaydellNow that the RTC_CHANGE event is no longer target-specific, we can move the pl031 back to a compile-once source file rather than a compile-per-target one.
--- hw/rtc/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/rtc/meson.build +1 -1
@@ -2,7 +2,7 @@ softmmu_ss.add(when: 'CONFIG_DS1338', if_true: files('ds1338.c')) softmmu_ss.add(when: 'CONFIG_M41T80', if_true: files('m41t80.c')) softmmu_ss.add(when: 'CONFIG_M48T59', if_true: files('m48t59.c')) -specific_ss.add(when: 'CONFIG_PL031', if_true: files('pl031.c')) +softmmu_ss.add(when: 'CONFIG_PL031', if_true: files('pl031.c')) softmmu_ss.add(when: 'CONFIG_TWL92230', if_true: files('twl92230.c')) softmmu_ss.add(when: ['CONFIG_ISA_BUS', 'CONFIG_M48T59'], if_true: files('m48t59-isa.c')) softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true: files('xlnx-zynqmp-rtc.c'))
Signature · 1 line
2.25.1
Re: [PATCH v2 3/3] hw/rtc: Compile pl031 once-only
Quoted 8 lines · Peter Maydell
Now that the
RTC_CHANGEevent is no longer target-specific, we can move the pl031 back to a compile-once source file rather than a compile-per-target one.Signed-off-by Peter Maydell <[email protected]>--- hw/rtc/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Hi Peter,
Quoted 20 lines · Peter Maydell
This patchset moves
RTC_CHANGEback to misc.json, effectively reverting commit183e4281a30962, which moved theRTC_CHANGEevent to the target schema. That change was an attempt to make the event target-specific to improve introspection, but the event isn't really
target-specific: it's machine or device specific. PuttingRTC_CHANGEin the target schema with an ifdef list reduces maintainability (by adding an if: list with a long list of targets that needs to be manually updated as architectures are added or removed or as new devices gain theRTC_CHANGEfunctionality) and increases compile time (by preventing RTC devices which emit the event from being "compile once" rather than "compile once per target", becauseqapi-events-misc-target.huses TARGET_* ifdefs, which are poisoned in "compile once" files.)Patch 2 fixes some minor documentation issues for the
RTC_CHANGEevent, noticed during development of the patchset.Patch 3 makes the pl031 a build-once file again, which was the initial motivation for the series.
Quoted 6 lines
Changes
v1->v2:
* patch 1 needs to change the #include line forpl031.c, now that the change to make that device emitRTC_CHANGEhas landed upstream
* patch 2 now also notes in theRTC_CHANGEdocumentation that not all devices/systems will emit the event (suggested by Markus)
* patch 3 is new
Thanks!
Eric
Quoted 21 lines
My default assumption is that this series will go in via the qapi tree; let me know if you'd prefer me to take it via target-arm instead.
thanks
-- PMMPeter Maydell (3):
qapi: MoveRTC_CHANGEback out of target schema
qapi: Document some missing details ofRTC_CHANGEevent hw/rtc: Compile pl031 once-onlyqapi/misc-target.json | 33 --------------------------------- qapi/misc.json | 24 ++++++++++++++++++++++++ hw/ppc/spapr_rtc.c | 2 +- hw/rtc/mc146818rtc.c | 2 +- hw/rtc/pl031.c | 2 +- hw/rtc/meson.build | 2 +- 6 files changed, 28 insertions(+), 37 deletions(-)
RFC PATCH 4/4 rtc: Have event RTC_CHANGE identify the RTC by QOM path
In reply to Peter MaydellEvent RTC_CHANGE is "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC? Which one changed? New @qom-path identifies it.
---
RFC because it's compile-tested only. Worthwhile? Let me know what you think.
qapi/misc.json | 4 +++- hw/ppc/spapr_rtc.c | 4 +++- hw/rtc/mc146818rtc.c | 3 ++- hw/rtc/pl031.c | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-)
qapi/misc.json +3 -1
@@ -536,6 +536,8 @@ # @offset: offset in seconds between base RTC clock (as specified # by -rtc base), and new RTC clock value # +# @qom-path: path to the RTC object in the QOM tree +# # Note: This event is rate-limited. # It is not guaranteed that the RTC in the system implements # this event, or even that the system has an RTC at all.
@@ -550,4 +552,4 @@ # ## { 'event': 'RTC_CHANGE', - 'data': { 'offset': 'int' } } + 'data': { 'offset': 'int', 'qom-path': 'str' } }
hw/ppc/spapr_rtc.c +3 -1
@@ -97,6 +97,7 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, SpaprMachineState *spapr, uint32_t nret, target_ulong rets) {SpaprRtcState *rtc = &spapr->rtc; + g_autofree const char *qom_path = NULL;struct tm tm;time_t new_s;int64_t host_ns;
@@ -120,7 +121,8 @@ static void rtas_set_time_of_day(PowerPCCPU *cpu, SpaprMachineState *spapr, }/* Generate a monitor event for the change */ -qapi_event_send_rtc_change (qemu_timedate_diff (&tm)); + qom_path =object_get_canonical_path (OBJECT (rtc)); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm), qom_path); host_ns =qemu_clock_get_ns (rtc_clock);
hw/rtc/mc146818rtc.c +2 -1
@@ -611,12 +611,13 @@ static void rtc_get_time(RTCState *s, struct tm *tm)static void rtc_set_time (RTCState *s) {struct tm tm; + g_autofree const char *qom_path = object_get_canonical_path(OBJECT(s));rtc_get_time (s, &tm); s->base_rtc =mktimegm (&tm); s->last_update =qemu_clock_get_ns (rtc_clock); -qapi_event_send_rtc_change (qemu_timedate_diff (&tm)); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm), qom_path); }static void rtc_set_cmos (RTCState *s,const struct tm *tm)
hw/rtc/pl031.c +2 -1
@@ -138,12 +138,13 @@ static void pl031_write(void * opaque, hwaddr offset,switch (offset) {case RTC_LR : { + g_autofree const char *qom_path = object_get_canonical_path(opaque);struct tm tm; s->tick_offset += value -pl031_get_count (s);qemu_get_timedate (&tm, s->tick_offset); -qapi_event_send_rtc_change (qemu_timedate_diff (&tm)); +qapi_event_send_rtc_change (qemu_timedate_diff (&tm), qom_path);pl031_set_alarm (s);break ;
Signature · 1 line
2.35.1
Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
Hi Markus,
Quoted 2 lines · Markus Armbruster
Event
RTC_CHANGEis "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC?
w.r.t. RTC, a machine having multiple RTC devices is silly...
Assuming one wants to emulate that; shouldn't all QMP events have a qom-path by default? Or have a generic "event-from-multiple-sources" flag which automatically add this field?
Quoted 12 lines
Which one changed? New @qom-path identifies it.
Signed-off-by Markus Armbruster <[email protected]>---
RFC because it's compile-tested only. Worthwhile? Let me know what you think.qapi/misc.json | 4 +++- hw/ppc/spapr_rtc.c | 4 +++- hw/rtc/mc146818rtc.c | 3 ++- hw/rtc/pl031.c | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-)
Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Markus Armbruster
Event
RTC_CHANGEis "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC?w.r.t. RTC, a machine having multiple RTC devices is silly...
I don't think we have any examples in the tree currently, but I bet real hardware like that does exist: the most plausible thing would be a board where there's an RTC built into the SoC but the board designers put an external RTC on the board (perhaps because it was better/more accurate/easier to make battery-backed).
In fact, here's an old bug report from a user trying to get their Debian system to use the battery-backed RTC as the "real" one rather than the non-battery-backed RTC device that's also part of the arm board they're using:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785445
-- PMM
Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
Quoted 14 lines · Peter Maydell
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Markus Armbruster
Event
RTC_CHANGEis "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC?w.r.t. RTC, a machine having multiple RTC devices is silly...
I don't think we have any examples in the tree currently, but I bet real hardware like that does exist: the most plausible thing would be a board where there's an RTC built into the SoC but the board designers put an external RTC on the board (perhaps because it was better/more accurate/easier to make battery-backed).
Quoted 5 lines
In fact, here's an old bug report from a user trying to get their Debian system to use the battery-backed RTC as the "real" one rather than the non-battery-backed RTC device that's also part of the arm board they're using:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785445
OK, thanks for this pointer.
Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
In reply to Peter MaydellQuoted 6 lines · Peter Maydell
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Markus Armbruster
Event
RTC_CHANGEis "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC?
Quoted 7 lines
Quoted 1 line
w.r.t. RTC, a machine having multiple RTC devices is silly...
I don't think we have any examples in the tree currently, but I bet real hardware like that does exist: the most plausible thing would be a board where there's an RTC built into the SoC but the board designers put an external RTC on the board (perhaps because it was better/more accurate/easier to make battery-backed).
Yes. like Aspeed machines.
C.
Quoted 8 lines
In fact, here's an old bug report from a user trying to get their Debian system to use the battery-backed RTC as the "real" one rather than the non-battery-backed RTC device that's also part of the arm board they're using:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785445-- PMM
Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
Hi Markus,
Quoted 2 lines · Markus Armbruster
Event
RTC_CHANGEis "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC?w.r.t. RTC, a machine having multiple RTC devices is silly...
Assuming one wants to emulate that; shouldn't all QMP events have a qom-path by default? Or have a generic "event-from-multiple-sources" flag which automatically add this field?
Not all events originate from a device, or even a QOM object.
The ones that do could all use a qom-path member, I guess.
[...]
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
Quoted 8 lines · Markus Armbruster
Quoted 6 lines · Philippe Mathieu-Daudé
Hi Markus,
Quoted 2 lines · Markus Armbruster
Event
RTC_CHANGEis "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC?
Quoted 7 lines
Quoted 5 lines
w.r.t. RTC, a machine having multiple RTC devices is silly...
Assuming one wants to emulate that; shouldn't all QMP events have a qom-path by default? Or have a generic "event-from-multiple-sources" flag which automatically add this field?
Not all events originate from a device, or even a QOM object.
OK.
Quoted 4 lines
The ones that do could all use a qom-path member, I guess.
[...]
Re: [PATCH RFC 4/4] rtc: Have event RTC_CHANGE identify the RTC by QOM path
In reply to Markus ArmbrusterQuoted 8 lines · Markus Armbruster
Event
RTC_CHANGEis "emitted when the guest changes the RTC time" (and the RTC supports the event). What if there's more than one RTC? Which one changed? New @qom-path identifies it.Signed-off-by Markus Armbruster <[email protected]>---
RFC because it's compile-tested only. Worthwhile? Let me know what you think.
Passes manual testing with mc146818rtc.
Markus Armbruster
AppliedQuoted 14 lines · Peter Maydell
This patchset moves
RTC_CHANGEback to misc.json, effectively reverting commit183e4281a30962, which moved theRTC_CHANGEevent to the target schema. That change was an attempt to make the event target-specific to improve introspection, but the event isn't really
target-specific: it's machine or device specific. PuttingRTC_CHANGEin the target schema with an ifdef list reduces maintainability (by adding an if: list with a long list of targets that needs to be manually updated as architectures are added or removed or as new devices gain theRTC_CHANGEfunctionality) and increases compile time (by preventing RTC devices which emit the event from being "compile once" rather than "compile once per target", becauseqapi-events-misc-target.huses TARGET_* ifdefs, which are poisoned in "compile once" files.)
Quoted 5 lines
Patch 2 fixes some minor documentation issues for the
RTC_CHANGEevent, noticed during development of the patchset.Patch 3 makes the pl031 a build-once file again, which was the initial motivation for the series.
Queued including my PATCH 4. Happy to unqueue it if there are objections, or the entire thing if you'd rather take it through the ARM tree. Thanks!