[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] mc146818rtc: add a way to generate RTC interrupts via QMP
From: |
Daniil Tatianin |
Subject: |
[PATCH] mc146818rtc: add a way to generate RTC interrupts via QMP |
Date: |
Thu, 25 Apr 2024 16:37:45 +0300 |
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.
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
hw/rtc/mc146818rtc.c | 15 +++++++++++++++
include/hw/rtc/mc146818rtc.h | 1 +
qapi/misc-target.json | 16 ++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index f4c1869232..6980a78d5f 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -116,6 +116,21 @@ void qmp_rtc_reset_reinjection(Error **errp)
}
}
+void qmp_rtc_notify(Error **errp)
+{
+ MC146818RtcState *s;
+
+ /*
+ * See:
+ * https://www.kernel.org/doc/Documentation/virtual/kvm/timekeeping.txt
+ */
+ QLIST_FOREACH(s, &rtc_devices, link) {
+ s->cmos_data[RTC_REG_B] |= REG_B_UIE;
+ 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..5229dffbbd 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_notify(Error **errp);
#endif /* HW_RTC_MC146818RTC_H */
diff --git a/qapi/misc-target.json b/qapi/misc-target.json
index 4e0a6492a9..20457b0acc 100644
--- a/qapi/misc-target.json
+++ b/qapi/misc-target.json
@@ -19,6 +19,22 @@
{ 'command': 'rtc-reset-reinjection',
'if': 'TARGET_I386' }
+##
+# @rtc-notify:
+#
+# Generate an RTC interrupt.
+#
+# Since: 9.1
+#
+# Example:
+#
+# -> { "execute": "rtc-notify" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'rtc-notify',
+ 'if': 'TARGET_I386' }
+
##
# @SevState:
#
--
2.34.1
- [PATCH] mc146818rtc: add a way to generate RTC interrupts via QMP,
Daniil Tatianin <=