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);
+ }
+}
+