diff mbox

[2/2] add rtc_reset_reinjection QMP command

Message ID 20140530140557.511405928@amt.cnet
State New
Headers show

Commit Message

Marcelo Tosatti May 30, 2014, 2:05 p.m. UTC
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.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Comments

Eric Blake May 30, 2014, 2:43 p.m. UTC | #1
On 05/30/2014 08:05 AM, Marcelo Tosatti 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.
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> 
> Index: qemu/hw/timer/mc146818rtc.c

Where's the usual --- separator?


> +
> +##
> +# @: rtc_reset_reinjection

s/_/-/g this is a new command, and should use dashes.
Marcelo Tosatti May 30, 2014, 8:11 p.m. UTC | #2
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.
Marcelo Tosatti June 2, 2014, 5:51 p.m. UTC | #3
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)
Eric Blake June 2, 2014, 7:05 p.m. UTC | #4
On 06/02/2014 11:51 AM, mtosatti@redhat.com 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.
Marcelo Tosatti June 2, 2014, 7:20 p.m. UTC | #5
On Mon, Jun 02, 2014 at 01:05:50PM -0600, Eric Blake wrote:
> On 06/02/2014 11:51 AM, mtosatti@redhat.com 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 ?
Eric Blake June 2, 2014, 7:41 p.m. UTC | #6
On 06/02/2014 01:20 PM, Marcelo Tosatti wrote:
> On Mon, Jun 02, 2014 at 01:05:50PM -0600, Eric Blake wrote:
>> On 06/02/2014 11:51 AM, mtosatti@redhat.com 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 ?

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.
diff mbox

Patch

Index: qemu/hw/timer/mc146818rtc.c
===================================================================
--- qemu.orig/hw/timer/mc146818rtc.c
+++ 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,7 @@  typedef struct RTCState {
     Notifier clock_reset_notifier;
     LostTickPolicy lost_tick_policy;
     Notifier suspend_notifier;
+    QLIST_ENTRY(RTCState) link;
 } RTCState;
 
 static void rtc_set_time(RTCState *s);
@@ -522,6 +524,19 @@  static void rtc_get_time(RTCState *s, st
         rtc_from_bcd(s, s->cmos_data[RTC_CENTURY]) * 100 - 1900;
 }
 
+
+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;
+    }
+}
+
 static void rtc_set_time(RTCState *s)
 {
     struct tm tm;
@@ -911,6 +926,7 @@  ISADevice *rtc_init(ISABus *bus, int bas
     } else {
         isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ);
     }
+    QLIST_INSERT_HEAD(&rtc_devices, s, link);
     return isadev;
 }
 
Index: qemu/qapi-schema.json
===================================================================
--- qemu.orig/qapi-schema.json
+++ 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' }
Index: qemu/qmp-commands.hx
===================================================================
--- qemu.orig/qmp-commands.hx
+++ qemu/qmp-commands.hx
@@ -3572,3 +3572,26 @@  Example:
                    } } ] }
 
 EQMP
+
+#if defined (CONFIG_MC146818RTC)
+    {
+        .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