* [PATCH v3] mc146818rtc: add a way to generate RTC interrupts via QMP
@ 2024-05-06 8:34 Daniil Tatianin
2024-05-14 6:57 ` Daniil Tatianin
0 siblings, 1 reply; 5+ messages in thread
From: Daniil Tatianin @ 2024-05-06 8:34 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Daniil Tatianin, Paolo Bonzini, Eric Blake, Markus Armbruster,
qemu-devel
This can be used to force-synchronize the time in guest after a long
stop-cont pause, which can be useful for serverless-type workload.
Also add a comment to highlight the fact that this (and one other QMP
command) only works for the MC146818 RTC controller.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
Changes since v0:
- Rename to rtc-inject-irq to match other similar API
- Add a comment to highlight that this only works for the I386 RTC
Changes since v1:
- Added a description below the QMP command to explain how it can be
used and what it does.
Changes since v2:
- Add a 'broadcast' suffix.
- Change the comments to explain the flags we're setting.
- Change the command description to fix styling & explain that it's a broadcast command.
---
hw/rtc/mc146818rtc.c | 20 ++++++++++++++++++++
include/hw/rtc/mc146818rtc.h | 1 +
qapi/misc-target.json | 19 +++++++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index 3379f92748..2b3754f5c6 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -107,6 +107,11 @@ static void rtc_coalesced_timer_update(MC146818RtcState *s)
static QLIST_HEAD(, MC146818RtcState) rtc_devices =
QLIST_HEAD_INITIALIZER(rtc_devices);
+/*
+ * NOTE:
+ * The two QMP functions below are _only_ implemented for the MC146818.
+ * All other RTC devices ignore this.
+ */
void qmp_rtc_reset_reinjection(Error **errp)
{
MC146818RtcState *s;
@@ -116,6 +121,21 @@ void qmp_rtc_reset_reinjection(Error **errp)
}
}
+void qmp_rtc_inject_irq_broadcast(Error **errp)
+{
+ MC146818RtcState *s;
+
+ QLIST_FOREACH(s, &rtc_devices, link) {
+ // Update-ended interrupt enable
+ s->cmos_data[RTC_REG_B] |= REG_B_UIE;
+
+ // Interrupt request flag | update interrupt flag
+ s->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_UF;
+
+ qemu_irq_raise(s->irq);
+ }
+}
+
static bool rtc_policy_slew_deliver_irq(MC146818RtcState *s)
{
kvm_reset_irq_delivered();
diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h
index 97cec0b3e8..e9dd0f9c72 100644
--- a/include/hw/rtc/mc146818rtc.h
+++ b/include/hw/rtc/mc146818rtc.h
@@ -56,5 +56,6 @@ MC146818RtcState *mc146818_rtc_init(ISABus *bus, int base_year,
void mc146818rtc_set_cmos_data(MC146818RtcState *s, int addr, int val);
int mc146818rtc_get_cmos_data(MC146818RtcState *s, int addr);
void qmp_rtc_reset_reinjection(Error **errp);
+void qmp_rtc_inject_irq_broadcast(Error **errp);
#endif /* HW_RTC_MC146818RTC_H */
diff --git a/qapi/misc-target.json b/qapi/misc-target.json
index 4e0a6492a9..7d388a3753 100644
--- a/qapi/misc-target.json
+++ b/qapi/misc-target.json
@@ -19,6 +19,25 @@
{ 'command': 'rtc-reset-reinjection',
'if': 'TARGET_I386' }
+##
+# @rtc-inject-irq-broadcast:
+#
+# Inject an RTC interrupt for all existing RTCs on the system.
+# The interrupt forces the guest to synchronize the time with RTC.
+# This is useful after a long stop-cont pause, which is common for
+# serverless-type workload.
+#
+# Since: 9.1
+#
+# Example:
+#
+# -> { "execute": "rtc-inject-irq-broadcast" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'rtc-inject-irq-broadcast',
+ 'if': 'TARGET_I386' }
+
##
# @SevState:
#
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3] mc146818rtc: add a way to generate RTC interrupts via QMP
2024-05-06 8:34 [PATCH v3] mc146818rtc: add a way to generate RTC interrupts via QMP Daniil Tatianin
@ 2024-05-14 6:57 ` Daniil Tatianin
2024-05-21 8:08 ` Daniil Tatianin
0 siblings, 1 reply; 5+ messages in thread
From: Daniil Tatianin @ 2024-05-14 6:57 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Paolo Bonzini, Eric Blake, Markus Armbruster,
qemu-devel@nongnu.org
[-- Attachment #1: Type: text/html, Size: 4098 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] mc146818rtc: add a way to generate RTC interrupts via QMP
2024-05-14 6:57 ` Daniil Tatianin
@ 2024-05-21 8:08 ` Daniil Tatianin
2024-05-27 17:01 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 5+ messages in thread
From: Daniil Tatianin @ 2024-05-21 8:08 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Paolo Bonzini, Eric Blake, Markus Armbruster,
qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 4145 bytes --]
Could you please take a look at this revision? I think I've taken
everyone's feedback into account.
Thank you!
On 5/14/24 9:57 AM, Daniil Tatianin wrote:
> ping :)
> 06.05.2024, 11:34, "Daniil Tatianin" <d-tatianin@yandex-team.ru>:
>
> This can be used to force-synchronize the time in guest after a long
> stop-cont pause, which can be useful for serverless-type workload.
>
> Also add a comment to highlight the fact that this (and one other QMP
> command) only works for the MC146818 RTC controller.
>
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> ---
>
> Changes since v0:
> - Rename to rtc-inject-irq to match other similar API
> - Add a comment to highlight that this only works for the I386 RTC
>
> Changes since v1:
> - Added a description below the QMP command to explain how it can be
> used and what it does.
>
> Changes since v2:
> - Add a 'broadcast' suffix.
> - Change the comments to explain the flags we're setting.
> - Change the command description to fix styling & explain that
> it's a broadcast command.
>
> ---
> hw/rtc/mc146818rtc.c | 20 ++++++++++++++++++++
> include/hw/rtc/mc146818rtc.h | 1 +
> qapi/misc-target.json | 19 +++++++++++++++++++
> 3 files changed, 40 insertions(+)
>
> diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
> index 3379f92748..2b3754f5c6 100644
> --- a/hw/rtc/mc146818rtc.c
> +++ b/hw/rtc/mc146818rtc.c
> @@ -107,6 +107,11 @@ static void
> rtc_coalesced_timer_update(MC146818RtcState *s)
> static QLIST_HEAD(, MC146818RtcState) rtc_devices =
> QLIST_HEAD_INITIALIZER(rtc_devices);
>
> +/*
> + * NOTE:
> + * The two QMP functions below are _only_ implemented for the
> MC146818.
> + * All other RTC devices ignore this.
> + */
> void qmp_rtc_reset_reinjection(Error **errp)
> {
> MC146818RtcState *s;
> @@ -116,6 +121,21 @@ void qmp_rtc_reset_reinjection(Error **errp)
> }
> }
>
> +void qmp_rtc_inject_irq_broadcast(Error **errp)
> +{
> + MC146818RtcState *s;
> +
> + QLIST_FOREACH(s, &rtc_devices, link) {
> + // Update-ended interrupt enable
> + s->cmos_data[RTC_REG_B] |= REG_B_UIE;
> +
> + // Interrupt request flag | update interrupt flag
> + s->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_UF;
> +
> + qemu_irq_raise(s->irq);
> + }
> +}
> +
> static bool rtc_policy_slew_deliver_irq(MC146818RtcState *s)
> {
> kvm_reset_irq_delivered();
> diff --git a/include/hw/rtc/mc146818rtc.h
> b/include/hw/rtc/mc146818rtc.h
> index 97cec0b3e8..e9dd0f9c72 100644
> --- a/include/hw/rtc/mc146818rtc.h
> +++ b/include/hw/rtc/mc146818rtc.h
> @@ -56,5 +56,6 @@ MC146818RtcState *mc146818_rtc_init(ISABus *bus,
> int base_year,
> void mc146818rtc_set_cmos_data(MC146818RtcState *s, int addr, int
> val);
> int mc146818rtc_get_cmos_data(MC146818RtcState *s, int addr);
> void qmp_rtc_reset_reinjection(Error **errp);
> +void qmp_rtc_inject_irq_broadcast(Error **errp);
>
> #endif /* HW_RTC_MC146818RTC_H */
> diff --git a/qapi/misc-target.json b/qapi/misc-target.json
> index 4e0a6492a9..7d388a3753 100644
> --- a/qapi/misc-target.json
> +++ b/qapi/misc-target.json
> @@ -19,6 +19,25 @@
> { 'command': 'rtc-reset-reinjection',
> 'if': 'TARGET_I386' }
>
> +##
> +# @rtc-inject-irq-broadcast:
> +#
> +# Inject an RTC interrupt for all existing RTCs on the system.
> +# The interrupt forces the guest to synchronize the time with RTC.
> +# This is useful after a long stop-cont pause, which is common for
> +# serverless-type workload.
> +#
> +# Since: 9.1
> +#
> +# Example:
> +#
> +# -> { "execute": "rtc-inject-irq-broadcast" }
> +# <- { "return": {} }
> +#
> +##
> +{ 'command': 'rtc-inject-irq-broadcast',
> + 'if': 'TARGET_I386' }
> +
> ##
> # @SevState:
> #
>
> --
> 2.34.1
>
[-- Attachment #2: Type: text/html, Size: 5997 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] mc146818rtc: add a way to generate RTC interrupts via QMP
2024-05-21 8:08 ` Daniil Tatianin
@ 2024-05-27 17:01 ` Philippe Mathieu-Daudé
2024-05-28 7:18 ` Daniil Tatianin
0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-27 17:01 UTC (permalink / raw)
To: Daniil Tatianin, Michael S. Tsirkin
Cc: Paolo Bonzini, Eric Blake, Markus Armbruster,
qemu-devel@nongnu.org
Hi Daniil,
On 21/5/24 10:08, Daniil Tatianin wrote:
> Could you please take a look at this revision? I think I've taken
> everyone's feedback into account.
Sorry for the delay, I missed your patch since you didn't Cc me
(Markus asked me to look at this).
Thanks for addressing the previous requests.
> Thank you!
>
> On 5/14/24 9:57 AM, Daniil Tatianin wrote:
>> ping :)
>> 06.05.2024, 11:34, "Daniil Tatianin" <d-tatianin@yandex-team.ru>:
>>
>> This can be used to force-synchronize the time in guest after a long
>> stop-cont pause, which can be useful for serverless-type workload.
>>
>> Also add a comment to highlight the fact that this (and one other QMP
>> command) only works for the MC146818 RTC controller.
>>
>> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
>> ---
>>
>> Changes since v0:
>> - Rename to rtc-inject-irq to match other similar API
>> - Add a comment to highlight that this only works for the I386 RTC
>>
>> Changes since v1:
>> - Added a description below the QMP command to explain how it can be
>> used and what it does.
>>
>> Changes since v2:
>> - Add a 'broadcast' suffix.
>> - Change the comments to explain the flags we're setting.
>> - Change the command description to fix styling & explain that
>> it's a broadcast command.
>>
>> ---
>> hw/rtc/mc146818rtc.c | 20 ++++++++++++++++++++
>> include/hw/rtc/mc146818rtc.h | 1 +
>> qapi/misc-target.json | 19 +++++++++++++++++++
>> 3 files changed, 40 insertions(+)
>>
>> diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
>> index 3379f92748..2b3754f5c6 100644
>> --- a/hw/rtc/mc146818rtc.c
>> +++ b/hw/rtc/mc146818rtc.c
>> @@ -107,6 +107,11 @@ static void
>> rtc_coalesced_timer_update(MC146818RtcState *s)
>> static QLIST_HEAD(, MC146818RtcState) rtc_devices =
>> QLIST_HEAD_INITIALIZER(rtc_devices);
>>
>> +/*
>> + * NOTE:
>> + * The two QMP functions below are _only_ implemented for the
>> MC146818.
>> + * All other RTC devices ignore this.
>> + */
>> void qmp_rtc_reset_reinjection(Error **errp)
>> {
>> MC146818RtcState *s;
>> @@ -116,6 +121,21 @@ void qmp_rtc_reset_reinjection(Error **errp)
>> }
>> }
>>
>> +void qmp_rtc_inject_irq_broadcast(Error **errp)
>> +{
>> + MC146818RtcState *s;
>> +
>> + QLIST_FOREACH(s, &rtc_devices, link) {
>> + // Update-ended interrupt enable
This doesn't pass the checkpatch script because it isn't QEMU coding
style:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#use-the-qemu-coding-style
>> + s->cmos_data[RTC_REG_B] |= REG_B_UIE;
>> +
>> + // Interrupt request flag | update interrupt flag
>> + s->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_UF;
>> +
>> + qemu_irq_raise(s->irq);
>> + }
>> +}
>> +
>> static bool rtc_policy_slew_deliver_irq(MC146818RtcState *s)
>> {
>> kvm_reset_irq_delivered();
>> diff --git a/include/hw/rtc/mc146818rtc.h
>> b/include/hw/rtc/mc146818rtc.h
>> index 97cec0b3e8..e9dd0f9c72 100644
>> --- a/include/hw/rtc/mc146818rtc.h
>> +++ b/include/hw/rtc/mc146818rtc.h
>> @@ -56,5 +56,6 @@ MC146818RtcState *mc146818_rtc_init(ISABus *bus,
>> int base_year,
>> void mc146818rtc_set_cmos_data(MC146818RtcState *s, int addr, int
>> val);
>> int mc146818rtc_get_cmos_data(MC146818RtcState *s, int addr);
>> void qmp_rtc_reset_reinjection(Error **errp);
>> +void qmp_rtc_inject_irq_broadcast(Error **errp);
>>
>> #endif /* HW_RTC_MC146818RTC_H */
>> diff --git a/qapi/misc-target.json b/qapi/misc-target.json
>> index 4e0a6492a9..7d388a3753 100644
>> --- a/qapi/misc-target.json
>> +++ b/qapi/misc-target.json
>> @@ -19,6 +19,25 @@
>> { 'command': 'rtc-reset-reinjection',
>> 'if': 'TARGET_I386' }
>>
Your new command doesn't make my life harder than the current
'rtc-reset-reinjection' command, so if this is useful to you,
I'm OK to:
Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(assuming the comment style is fixed).
I'll see later how to deal with that with heterogeneous
emulation.
Regards,
Phil.
>> +##
>> +# @rtc-inject-irq-broadcast:
>> +#
>> +# Inject an RTC interrupt for all existing RTCs on the system.
>> +# The interrupt forces the guest to synchronize the time with RTC.
>> +# This is useful after a long stop-cont pause, which is common for
>> +# serverless-type workload.
>> +#
>> +# Since: 9.1
>> +#
>> +# Example:
>> +#
>> +# -> { "execute": "rtc-inject-irq-broadcast" }
>> +# <- { "return": {} }
>> +#
>> +##
>> +{ 'command': 'rtc-inject-irq-broadcast',
>> + 'if': 'TARGET_I386' }
>> +
>> ##
>> # @SevState:
>> #
>>
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] mc146818rtc: add a way to generate RTC interrupts via QMP
2024-05-27 17:01 ` Philippe Mathieu-Daudé
@ 2024-05-28 7:18 ` Daniil Tatianin
0 siblings, 0 replies; 5+ messages in thread
From: Daniil Tatianin @ 2024-05-28 7:18 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Michael S. Tsirkin
Cc: Paolo Bonzini, Eric Blake, Markus Armbruster,
qemu-devel@nongnu.org
On 5/27/24 8:01 PM, Philippe Mathieu-Daudé wrote:
> Hi Daniil,
>
> On 21/5/24 10:08, Daniil Tatianin wrote:
>> Could you please take a look at this revision? I think I've taken
>> everyone's feedback into account.
>
> Sorry for the delay, I missed your patch since you didn't Cc me
> (Markus asked me to look at this).
Oops, my bad for forgetting to Cc you!
>
> Thanks for addressing the previous requests.
>
>> Thank you!
>>
>> On 5/14/24 9:57 AM, Daniil Tatianin wrote:
>>> ping :)
>>> 06.05.2024, 11:34, "Daniil Tatianin" <d-tatianin@yandex-team.ru>:
>>>
>>> This can be used to force-synchronize the time in guest after a
>>> long
>>> stop-cont pause, which can be useful for serverless-type workload.
>>>
>>> Also add a comment to highlight the fact that this (and one
>>> other QMP
>>> command) only works for the MC146818 RTC controller.
>>>
>>> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
>>> ---
>>>
>>> Changes since v0:
>>> - Rename to rtc-inject-irq to match other similar API
>>> - Add a comment to highlight that this only works for the I386 RTC
>>>
>>> Changes since v1:
>>> - Added a description below the QMP command to explain how it
>>> can be
>>> used and what it does.
>>>
>>> Changes since v2:
>>> - Add a 'broadcast' suffix.
>>> - Change the comments to explain the flags we're setting.
>>> - Change the command description to fix styling & explain that
>>> it's a broadcast command.
>>>
>>> ---
>>> hw/rtc/mc146818rtc.c | 20 ++++++++++++++++++++
>>> include/hw/rtc/mc146818rtc.h | 1 +
>>> qapi/misc-target.json | 19 +++++++++++++++++++
>>> 3 files changed, 40 insertions(+)
>>>
>>> diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
>>> index 3379f92748..2b3754f5c6 100644
>>> --- a/hw/rtc/mc146818rtc.c
>>> +++ b/hw/rtc/mc146818rtc.c
>>> @@ -107,6 +107,11 @@ static void
>>> rtc_coalesced_timer_update(MC146818RtcState *s)
>>> static QLIST_HEAD(, MC146818RtcState) rtc_devices =
>>> QLIST_HEAD_INITIALIZER(rtc_devices);
>>>
>>> +/*
>>> + * NOTE:
>>> + * The two QMP functions below are _only_ implemented for the
>>> MC146818.
>>> + * All other RTC devices ignore this.
>>> + */
>>> void qmp_rtc_reset_reinjection(Error **errp)
>>> {
>>> MC146818RtcState *s;
>>> @@ -116,6 +121,21 @@ void qmp_rtc_reset_reinjection(Error **errp)
>>> }
>>> }
>>>
>>> +void qmp_rtc_inject_irq_broadcast(Error **errp)
>>> +{
>>> + MC146818RtcState *s;
>>> +
>>> + QLIST_FOREACH(s, &rtc_devices, link) {
>>> + // Update-ended interrupt enable
>
> This doesn't pass the checkpatch script because it isn't QEMU coding
> style:
> https://www.qemu.org/docs/master/devel/submitting-a-patch.html#use-the-qemu-coding-style
>
>
Looks like // comments are not allowed, will fix.
>>> + s->cmos_data[RTC_REG_B] |= REG_B_UIE;
>>> +
>>> + // Interrupt request flag | update interrupt flag
>>> + s->cmos_data[RTC_REG_C] |= REG_C_IRQF | REG_C_UF;
>>> +
>>> + qemu_irq_raise(s->irq);
>>> + }
>>> +}
>>> +
>>> static bool rtc_policy_slew_deliver_irq(MC146818RtcState *s)
>>> {
>>> kvm_reset_irq_delivered();
>>> diff --git a/include/hw/rtc/mc146818rtc.h
>>> b/include/hw/rtc/mc146818rtc.h
>>> index 97cec0b3e8..e9dd0f9c72 100644
>>> --- a/include/hw/rtc/mc146818rtc.h
>>> +++ b/include/hw/rtc/mc146818rtc.h
>>> @@ -56,5 +56,6 @@ MC146818RtcState *mc146818_rtc_init(ISABus *bus,
>>> int base_year,
>>> void mc146818rtc_set_cmos_data(MC146818RtcState *s, int addr, int
>>> val);
>>> int mc146818rtc_get_cmos_data(MC146818RtcState *s, int addr);
>>> void qmp_rtc_reset_reinjection(Error **errp);
>>> +void qmp_rtc_inject_irq_broadcast(Error **errp);
>>>
>>> #endif /* HW_RTC_MC146818RTC_H */
>>> diff --git a/qapi/misc-target.json b/qapi/misc-target.json
>>> index 4e0a6492a9..7d388a3753 100644
>>> --- a/qapi/misc-target.json
>>> +++ b/qapi/misc-target.json
>>> @@ -19,6 +19,25 @@
>>> { 'command': 'rtc-reset-reinjection',
>>> 'if': 'TARGET_I386' }
>>>
>
> Your new command doesn't make my life harder than the current
> 'rtc-reset-reinjection' command, so if this is useful to you,
> I'm OK to:
> Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> (assuming the comment style is fixed).
>
> I'll see later how to deal with that with heterogeneous
> emulation.
>
> Regards,
>
> Phil.
Thank you!
>>> +##
>>> +# @rtc-inject-irq-broadcast:
>>> +#
>>> +# Inject an RTC interrupt for all existing RTCs on the system.
>>> +# The interrupt forces the guest to synchronize the time with RTC.
>>> +# This is useful after a long stop-cont pause, which is common for
>>> +# serverless-type workload.
>>> +#
>>> +# Since: 9.1
>>> +#
>>> +# Example:
>>> +#
>>> +# -> { "execute": "rtc-inject-irq-broadcast" }
>>> +# <- { "return": {} }
>>> +#
>>> +##
>>> +{ 'command': 'rtc-inject-irq-broadcast',
>>> + 'if': 'TARGET_I386' }
>>> +
>>> ##
>>> # @SevState:
>>> #
>>>
>>> --
>>> 2.34.1
>>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-05-28 7:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06 8:34 [PATCH v3] mc146818rtc: add a way to generate RTC interrupts via QMP Daniil Tatianin
2024-05-14 6:57 ` Daniil Tatianin
2024-05-21 8:08 ` Daniil Tatianin
2024-05-27 17:01 ` Philippe Mathieu-Daudé
2024-05-28 7:18 ` Daniil Tatianin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).