Skip to contentSkip to conversation

mc146818rtc: add rtc_reset_reinjection QMP command

PATCH In review [email protected] 2 participants 10 messages Jun 2, 2014 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

cover add QMP command to reset rtc interrupt backlog (v3)

It is necessary to reset RTC interrupt backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed), resulting in an incorrect guest time.

---

changelog:

v3:
- add object_property_add_alias (Paolo)
- fix #ifdefs (Paolo)

#2 lore raw

PATCH 1/3 mc146818rtc: add rtc_reset_reinjection QMP command

It is necessary to reset RTC interrupt reinjection backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed), resulting in an incorrect guest time.

hw/timer/mc146818rtc.c +22 -0
Index: qemu/hw/timer/mc146818rtc.c
===================================================================
@@ -26,6 +26,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/timer/mc146818rtc.h"
 #include "qapi/visitor.h"
+#include "qmp-commands.h"
 
 #ifdef TARGET_I386
 #include "hw/i386/apic.h"
@@ -84,6 +85,9 @@ typedef struct RTCState {
     Notifier clock_reset_notifier;
     LostTickPolicy lost_tick_policy;
     Notifier suspend_notifier;
+#ifdef TARGET_I386
+    QLIST_ENTRY(RTCState) link;
+#endif
 } RTCState;
 
 static void rtc_set_time(RTCState *s);
@@ -522,6 +526,20 @@ static void rtc_get_time(RTCState *s, st
         rtc_from_bcd(s, s->cmos_data[RTC_CENTURY]) * 100 - 1900;
 }
 
+#ifdef TARGET_I386
+static QLIST_HEAD(, RTCState) rtc_devices =
+    QLIST_HEAD_INITIALIZER(rtc_devices);
+
+void qmp_rtc_reset_reinjection(Error **errp)
+{
+    RTCState *s;
+
+    QLIST_FOREACH(s, &rtc_devices, link) {
+        s->irq_coalesced = 0;
+    }
+}
+#endif
+
 static void rtc_set_time(RTCState *s)
 {
     struct tm tm;
@@ -911,6 +929,10 @@ ISADevice *rtc_init(ISABus *bus, int bas
     } else {
         isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ);
     }
+#ifdef TARGET_I386
+    QLIST_INSERT_HEAD(&rtc_devices, s, link);
+#endif
+
     return isadev;
 }
 
qapi-schema.json +12 -0
Index: qemu/qapi-schema.json
===================================================================
@@ -4722,3 +4722,15 @@
               'btn'     : 'InputBtnEvent',
               'rel'     : 'InputMoveEvent',
               'abs'     : 'InputMoveEvent' } }
+
+##
+# @: rtc-reset-reinjection
+#
+# This command will reset RTC's interrupt reinjection backlog.
+# Can be used if another mechanism to synchronize guest time
+# is in effect, for example QEMU guest agents guest-set-time
+# command.
+#
+# Since: 2.1
+##
+{ 'command': 'rtc-reset-reinjection' }
qmp-commands.hx +23 -0
Index: qemu/qmp-commands.hx
===================================================================
@@ -3572,3 +3572,26 @@ Example:
                    } } ] }
 
 EQMP
+
+#if defined (TARGET_I386)
+    {
+        .name       = "rtc_reset_reinjection",
+        .args_type  = "",
+        .mhandler.cmd_new = qmp_marshal_input_rtc_reset_reinjection,
+    },
+#endif
+
+SQMP
+rtc-reset-reinjection
+---------------------
+
+Reset RTC's interrupt reinjection backlog.
+
+Arguments: None.
+
+Example:
+
+-> { "execute": "rtc-reset-reinjection" }
+<- { "return": {} }
+
+EQMP
#3 lore raw
Quoted 10 lines · On 06/02/2014 11:51 AM, [email protected] wrote:

It is necessary to reset RTC interrupt reinjection backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed), resulting in an incorrect guest time.

Index: qemu/hw/timer/mc146818rtc.c

Still no --- separator between your commit message and the patch body. Are you using 'git send-email'?

qapi-schema.json line 4727

Quoted 11 lines

Index: qemu/qapi-schema.json
===================================================================

qapi-schema.json +3 -0
@@ -4722,3 +4722,15 @@
               'btn'     : 'InputBtnEvent',
               'rel'     : 'InputMoveEvent',
               'abs'     : 'InputMoveEvent' } }
+
+##
+# @: rtc-reset-reinjection

s/: // to resemble most other commands

qapi-schema.json line 4729

Quoted 2 lines
qapi-schema.json +2 -0
+#
+# This command will reset RTC's interrupt reinjection backlog.

s/RTC's/the RTC/

qapi-schema.json line 4731

Quoted 2 lines
qapi-schema.json +2 -0
+# Can be used if another mechanism to synchronize guest time
+# is in effect, for example QEMU guest agents guest-set-time

s/agents/agent's/

Quoted 10 lines
qapi-schema.json +5 -0
+# command.
+#
+# Since: 2.1
+##
+{ 'command': 'rtc-reset-reinjection' }

Index: qemu/qmp-commands.hx
===================================================================

qmp-commands.hx Example: · line 3578

Quoted 7 lines
qmp-commands.hx +4 -0
@@ -3572,3 +3572,26 @@ Example:
                    } } ] }
 
 EQMP
+
+#if defined (TARGET_I386)
+    {
+        .name       = "rtc_reset_reinjection",

s/rtc_reset_reinjection/rtc-reset-reinjection/

Quoted 8 lines
qmp-commands.hx +8 -0
+        .args_type  = "",
+        .mhandler.cmd_new = qmp_marshal_input_rtc_reset_reinjection,
+    },
+#endif
+
+SQMP
+rtc-reset-reinjection
+---------------------
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#4 lore raw
Quoted 8 lines · Eric Blake
Quoted 7 lines · On 06/02/2014 11:51 AM, [email protected] wrote:

It is necessary to reset RTC interrupt reinjection backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed), resulting in an incorrect guest time.

Quoted 6 lines
Quoted 3 lines

Index: qemu/hw/timer/mc146818rtc.c

Still no --- separator between your commit message and the patch body. Are you using 'git send-email'?

OK, diffstats on every patch.

Quoted 5 lines
Quoted 5 lines

Index: qemu/qapi-schema.json
===================================================================

qapi-schema.json +0 -0
@@ -4722,3 +4722,15 @@
Quoted 8 lines

qapi-schema.json line 4727

Quoted 6 lines
qapi-schema.json +3 -0
               'btn'     : 'InputBtnEvent',
               'rel'     : 'InputMoveEvent',
               'abs'     : 'InputMoveEvent' } }
+
+##
+# @: rtc-reset-reinjection

s/: // to resemble most other commands

Several commands have ":". What is the correct syntax and why?

Quoted 8 lines

qapi-schema.json line 4729

Quoted 1 line
qapi-schema.json +1 -0
+# This command will reset RTC's interrupt reinjection backlog.

s/RTC's/the RTC/

qapi-schema.json line 4731

Quoted 2 lines
qapi-schema.json +2 -0
+# Can be used if another mechanism to synchronize guest time
+# is in effect, for example QEMU guest agents guest-set-time

s/agents/agent's/

Fixed.

Quoted 12 lines
Quoted 12 lines
qapi-schema.json +5 -0
+# command.
+#
+# Since: 2.1
+##
+{ 'command': 'rtc-reset-reinjection' }

Index: qemu/qmp-commands.hx
===================================================================

qmp-commands.hx +0 -0
@@ -3572,3 +3572,26 @@ Example:
                    } } ] }
 
Quoted 7 lines

qmp-commands.hx Example: · line 3578

Quoted 5 lines
qmp-commands.hx +4 -0
 EQMP
+
+#if defined (TARGET_I386)
+    {
+        .name       = "rtc_reset_reinjection",

s/rtc_reset_reinjection/rtc-reset-reinjection/

This is a function name.

#5 lore raw
Quoted 7 lines · Marcelo Tosatti
Quoted 5 lines · Eric Blake
Quoted 4 lines · On 06/02/2014 11:51 AM, [email protected] wrote:

It is necessary to reset RTC interrupt reinjection backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Quoted 7 lines
Quoted 5 lines

qapi-schema.json line 4727

Quoted 3 lines
qapi-schema.json +3 -0
+
+##
+# @: rtc-reset-reinjection

s/: // to resemble most other commands

Several commands have ":". What is the correct syntax and why?

Alas, we don't have any automated program that strips these stylized comments and turns them into formal documentation. But the goal is that some day we might, at which point, being consistent in our style is the most likely to be successful. The prevalent style appears to be:

##
# @command:
#
# Short summary
#
# @foo: describe mandatory option foo
#
# @bar: #optional describe optional option bar, and its default value
# if omitted
#
# Returns: what to expect from the command
#
# Since: version it was introduced
##
{ 'command' ... }

Although I will admit that '@command' vs. '@command:' didn't have a clear winner. Maybe someone with OCD wants to do a pure cleanup patch to get the file into a consistent state? Until then, I'm pointing out where things are definitely different (your '@: command' was an outlier)

Quoted 9 lines
Quoted 7 lines

qmp-commands.hx Example: · line 3578

Quoted 5 lines

EQMP

qmp-commands.hx +4 -0
+
+#if defined (TARGET_I386)
+    {
+        .name       = "rtc_reset_reinjection",

s/rtc_reset_reinjection/rtc-reset-reinjection/

This is a function name.

No, it is a QMP command name. See "send-key" for an example.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw

PATCH 2/3 add object_property_add_alias

In reply to [email protected]

Allowing addition of a link without keeping pointer-to-pointer.

include/qom/object.h +13 -0
Index: qemu/include/qom/object.h
===================================================================
@@ -1073,6 +1073,19 @@ typedef enum {
 } ObjectPropertyLinkFlags;
 
 /**
+ * object_property_add_alias:
+ * @obj: the object to add a property to
+ * @name: the name of the property
+ * @alias: the alias object
+ * @errp: if an error occurs, a pointer to an area to store the area
+ *
+ * Add a link under obj, named name, pointing to alias.
+ *
+ */
+void object_property_add_alias(Object *obj, const char *name,
+                               Object *alias, Error **errp);
+
+/**
  * object_property_allow_set_link:
  *
  * The default implementation of the object_property_add_link() check()
qom/object.c +59 -14

115 lines not on this page · raw message

#7 lore raw

PATCH 3/3 mc146818rtc: add "rtc" link to "/machine"

In reply to [email protected]

Add a link to rtc under /machine providing a stable location for management apps to query "date" field.

{"execute":"qom-get","arguments":{"path":"/machine/rtc","property":"date"} }

Suggested by Paolo Bonzini.

hw/timer/mc146818rtc.c +9 -0
Index: qemu/hw/timer/mc146818rtc.c
===================================================================
@@ -911,6 +911,9 @@ static void rtc_realizefn(DeviceState *d
 
     object_property_add(OBJECT(s), "date", "struct tm",
                         rtc_get_date, NULL, NULL, s, NULL);
+
+    object_property_add_alias(qdev_get_machine(), "rtc", OBJECT(s),
+                              &error_abort);
 }
 
 ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
@@ -954,11 +957,17 @@ static void rtc_class_initfn(ObjectClass
     dc->cannot_instantiate_with_device_add_yet = true;
 }
 
+static void rtc_finalize(Object *obj)
+{
+    object_property_del(qdev_get_machine(), "rtc", NULL);
+}
+
 static const TypeInfo mc146818rtc_info = {
     .name          = TYPE_MC146818_RTC,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(RTCState),
     .class_init    = rtc_class_initfn,
+    .instance_finalize = rtc_finalize,
 };
 
 static void mc146818rtc_register_types(void)
#8 lore raw

Re: [Qemu-devel] [patch 0/3] add QMP command to reset rtc interrupt backlog (v3)

In reply to [email protected]
Quoted 6 lines · On 06/02/2014 11:51 AM, [email protected] wrote:

It is necessary to reset RTC interrupt backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed), resulting in an incorrect guest time.

Please send v3 of a series as a new top-level thread instead of buried as a reply to v2.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#9 lore raw

Re: [Qemu-devel] [patch 0/3] add QMP command to reset rtc interrupt backlog (v3)

Quoted 10 lines · Eric Blake
Quoted 6 lines · On 06/02/2014 11:51 AM, [email protected] wrote:

It is necessary to reset RTC interrupt backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed), resulting in an incorrect guest time.

Please send v3 of a series as a new top-level thread instead of buried as a reply to v2.

I prefer to delete whole threads i am not interested in.

What is the problem with threads for you ?

#10 lore raw

Re: [Qemu-devel] [patch 0/3] add QMP command to reset rtc interrupt backlog (v3)

Quoted 9 lines · Marcelo Tosatti
Quoted 8 lines · Eric Blake
Quoted 6 lines · On 06/02/2014 11:51 AM, [email protected] wrote:

It is necessary to reset RTC interrupt backlog if guest time is synchronized via a different mechanism, such as QGA's guest-set-time command.

Failing to do so causes both corrections to be applied (summed), resulting in an incorrect guest time.

Quoted 6 lines
Quoted 2 lines

Please send v3 of a series as a new top-level thread instead of buried as a reply to v2.

I prefer to delete whole threads i am not interested in.

What is the problem with threads for you ?

Threads are good. But one thread per version of a series is better than one thread for ALL versions of the series, as documented in our patch submission guidelines:
http://wiki.qemu.org/Contribute/SubmitAPatch

Since most of contributors are already doing that, most reviewers have gotten into the habit of assuming that any replies to a series are in regards to things to fix, rather than looking for a new version of the series. I'd rather kill several threads for versions of a series, then later learn that a new revision of the series needs my review; than kill a single thread, at which point I no longer see any new versions in my inbox but also lose any chance to be easily pulled back in to that topic.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org