On 26/4/24 11:48, Philippe Mathieu-Daudé wrote:
Hi Daniil, Markus,

On 26/4/24 10:39, Markus Armbruster wrote:
Daniil Tatianin <d-tatia...@yandex-team.ru> writes:

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

Note for later: qmp_rtc_notify() works on all realized mc146818rtc
devices.  Other kinds of RTC devices are silently ignored.  Just like
qmp_rtc_reset_reinjection().

IMO to avoid any future ambiguity (in heterogeneous machines), this
command must take a QOM device path (or a list of) and only notify
those.

If you disagree, at least please rename the command/method using
"broadcast" for trailer.

Reply via email to