Skip to contentSkip to conversation

xen-hvm: Emit RTC_CHANGE upon TIMEOFFSET ioreq

PATCH In review Ross Lagerwall 2 participants 3 messages Jan 8 – Feb 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen-hvm: Emit RTC_CHANGE upon TIMEOFFSET ioreq

When the guest writes to the RTC, the write is intercepted and emulated by Xen and the time difference is broadcasted as a TIMEOFFSET ioreq. Emit an RTC_CHANGE QMP event when this happens rather than ignoring it so that something can make use of the information (e.g. the toolstack can persist it between VM starts).

---
 hw/xen/xen-hvm-common.c | 2 ++
 1 file changed, 2 insertions(+)
hw/xen/xen-hvm-common.c +2 -0
index 59c73dfaeb59..9b539f5c5c56 100644
@@ -4,6 +4,7 @@
 #include "qemu/error-report.h"
 #include "qemu/target-info.h"
 #include "qapi/error.h"
+#include "qapi/qapi-events-misc.h"
 #include "exec/target_page.h"
 #include "trace.h"
 
@@ -471,6 +472,7 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req)
             cpu_ioreq_move(req);
             break;
         case IOREQ_TYPE_TIMEOFFSET:
+            qapi_event_send_rtc_change((int64_t)req->data, NULL);
             break;
         case IOREQ_TYPE_INVALIDATE:
             xen_invalidate_map_cache();
Signature · 1 line
2.52.0
#1 lore raw
Quoted 16 lines · Ross Lagerwall

When the guest writes to the RTC, the write is intercepted and emulated by Xen and the time difference is broadcasted as a TIMEOFFSET ioreq. Emit an RTC_CHANGE QMP event when this happens rather than ignoring it so that something can make use of the information (e.g. the toolstack can persist it between VM starts).

---
 hw/xen/xen-hvm-common.c | 2 ++
 1 file changed, 2 insertions(+)
hw/xen/xen-hvm-common.c +0 -0
index 59c73dfaeb59..9b539f5c5c56 100644

hw/xen/xen-hvm-common.c static void handle_ioreq(XenIOState *state, ioreq_t *req) · line 475

Quoted 4 lines
hw/xen/xen-hvm-common.c +1 -0
@@ -471,6 +472,7 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req)
             cpu_ioreq_move(req);
             break;
         case IOREQ_TYPE_TIMEOFFSET:
+            qapi_event_send_rtc_change((int64_t)req->data, NULL);

Would you be fine to replace NULL by ""? I've notice a TODO in visit_type_str() at
https://gitlab.com/qemu-project/qemu/-/blob/master/qapi/qapi-visit-core.c#L344
which is one of the function doing something with that parameter.

With that, which I can do on commit: Acked-by: Anthony PERARD <[email protected]>

Thanks,

Signature · 1 line
Anthony PERARD
#2 lore raw
Quoted 27 lines · Anthony PERARD
Quoted 16 lines · Ross Lagerwall

When the guest writes to the RTC, the write is intercepted and emulated by Xen and the time difference is broadcasted as a TIMEOFFSET ioreq. Emit an RTC_CHANGE QMP event when this happens rather than ignoring it so that something can make use of the information (e.g. the toolstack can persist it between VM starts).

---
  hw/xen/xen-hvm-common.c | 2 ++
  1 file changed, 2 insertions(+)
hw/xen/xen-hvm-common.c +0 -0
index 59c73dfaeb59..9b539f5c5c56 100644

hw/xen/xen-hvm-common.c static void handle_ioreq(XenIOState *state, ioreq_t *req) · line 475

Quoted 4 lines
hw/xen/xen-hvm-common.c +1 -0
@@ -471,6 +472,7 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req)
              cpu_ioreq_move(req);
              break;
          case IOREQ_TYPE_TIMEOFFSET:
+            qapi_event_send_rtc_change((int64_t)req->data, NULL);

Would you be fine to replace NULL by ""? I've notice a TODO in visit_type_str() at
https://gitlab.com/qemu-project/qemu/-/blob/master/qapi/qapi-visit-core.c#L344
which is one of the function doing something with that parameter.

Quoted 2 lines

With that, which I can do on commit: Acked-by: Anthony PERARD <[email protected]>

Sure, fine with me.

Thanks,
Ross