All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command
@ 2014-06-25 11:40 Michael S. Tsirkin
  2014-06-25 13:58 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-06-25 11:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marcelo Tosatti, Markus Armbruster, Luiz Capitulino,
	Stefan Hajnoczi, =?UTF-8?q?Andreas=20F=C3=A4rber?=

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.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Marcelo, is this right?

Changes from v3:
    rebase on top of master
    fixes error code
    drop dead code

 qapi-schema.json       | 12 ++++++++++++
 hw/timer/mc146818rtc.c | 18 ++++++++++++++++++
 monitor.c              |  7 +++++++
 qmp-commands.hx        | 23 +++++++++++++++++++++++
 4 files changed, 60 insertions(+)

diff --git a/qapi-schema.json b/qapi-schema.json
index f490403..a282805 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3288,3 +3288,15 @@
 # Since: 2.1
 ##
 { 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] }
+
+##
+# @rtc-reset-reinjection
+#
+# This command will reset the RTC interrupt reinjection backlog.
+# Can be used if another mechanism to synchronize guest time
+# is in effect, for example QEMU guest agent's guest-set-time
+# command.
+#
+# Since: 2.1
+##
+{ 'command': 'rtc-reset-reinjection' }
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 1201f90..5bd8710 100644
--- a/hw/timer/mc146818rtc.c
+++ b/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,20 @@ static void rtc_get_time(RTCState *s, struct tm *tm)
         rtc_from_bcd(s, s->cmos_data[RTC_CENTURY]) * 100 - 1900;
 }
 
+static QLIST_HEAD(, RTCState) rtc_devices =
+    QLIST_HEAD_INITIALIZER(rtc_devices);
+
+#ifdef TARGET_I386
+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;
@@ -910,6 +926,8 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
     } else {
         isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ);
     }
+    QLIST_INSERT_HEAD(&rtc_devices, s, link);
+
     return isadev;
 }
 
diff --git a/monitor.c b/monitor.c
index 8c17f89..f7a0206 100644
--- a/monitor.c
+++ b/monitor.c
@@ -5483,3 +5483,10 @@ QemuOptsList qemu_mon_opts = {
         { /* end of list */ }
     },
 };
+
+#ifndef TARGET_I386
+void qmp_rtc_reset_reinjection(Error **errp)
+{
+    error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
+}
+#endif
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e4a1c80..17c09de 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3661,3 +3661,26 @@ Example:
                  { "slot": "3", "slot-type": "DIMM", "source": 0, "status": 0}
    ]}
 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 the RTC interrupt reinjection backlog.
+
+Arguments: None.
+
+Example:
+
+-> { "execute": "rtc-reset-reinjection" }
+<- { "return": {} }
+
+EQMP
-- 
MST

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command
  2014-06-25 11:40 [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command Michael S. Tsirkin
@ 2014-06-25 13:58 ` Eric Blake
  2014-06-25 15:18 ` Marcelo Tosatti
  2014-06-25 19:51 ` Luiz Capitulino
  2 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2014-06-25 13:58 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: Andreas Färber, Marcelo Tosatti, Markus Armbruster,
	Stefan Hajnoczi, Luiz Capitulino

[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]

On 06/25/2014 05:40 AM, Michael S. Tsirkin 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.
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> Marcelo, is this right?
> 
> Changes from v3:
>     rebase on top of master
>     fixes error code
>     drop dead code
> 
>  qapi-schema.json       | 12 ++++++++++++
>  hw/timer/mc146818rtc.c | 18 ++++++++++++++++++
>  monitor.c              |  7 +++++++
>  qmp-commands.hx        | 23 +++++++++++++++++++++++
>  4 files changed, 60 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command
  2014-06-25 11:40 [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command Michael S. Tsirkin
  2014-06-25 13:58 ` Eric Blake
@ 2014-06-25 15:18 ` Marcelo Tosatti
  2014-06-25 19:51 ` Luiz Capitulino
  2 siblings, 0 replies; 5+ messages in thread
From: Marcelo Tosatti @ 2014-06-25 15:18 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Markus Armbruster, qemu-devel, Stefan Hajnoczi, Luiz Capitulino,
	=?UTF-8?q?Andreas=20F=C3=A4rber?=

On Wed, Jun 25, 2014 at 02:40:12PM +0300, Michael S. Tsirkin 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.
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> Marcelo, is this right?
> 
> Changes from v3:
>     rebase on top of master
>     fixes error code
>     drop dead code

Yes, sorry about the trouble.

Thanks a lot Michael.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command
  2014-06-25 11:40 [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command Michael S. Tsirkin
  2014-06-25 13:58 ` Eric Blake
  2014-06-25 15:18 ` Marcelo Tosatti
@ 2014-06-25 19:51 ` Luiz Capitulino
  2014-06-26  5:59   ` Michael S. Tsirkin
  2 siblings, 1 reply; 5+ messages in thread
From: Luiz Capitulino @ 2014-06-25 19:51 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Marcelo Tosatti, qemu-devel, Markus Armbruster, Stefan Hajnoczi,
	Andreas Färber

On Wed, 25 Jun 2014 14:40:12 +0300
"Michael S. Tsirkin" <mst@redhat.com> 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.
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Should this go via qmp tree or are you going to apply it to your tree?

> ---
> 
> Marcelo, is this right?
> 
> Changes from v3:
>     rebase on top of master
>     fixes error code
>     drop dead code
> 
>  qapi-schema.json       | 12 ++++++++++++
>  hw/timer/mc146818rtc.c | 18 ++++++++++++++++++
>  monitor.c              |  7 +++++++
>  qmp-commands.hx        | 23 +++++++++++++++++++++++
>  4 files changed, 60 insertions(+)
> 
> diff --git a/qapi-schema.json b/qapi-schema.json
> index f490403..a282805 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3288,3 +3288,15 @@
>  # Since: 2.1
>  ##
>  { 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] }
> +
> +##
> +# @rtc-reset-reinjection
> +#
> +# This command will reset the RTC interrupt reinjection backlog.
> +# Can be used if another mechanism to synchronize guest time
> +# is in effect, for example QEMU guest agent's guest-set-time
> +# command.
> +#
> +# Since: 2.1
> +##
> +{ 'command': 'rtc-reset-reinjection' }
> diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
> index 1201f90..5bd8710 100644
> --- a/hw/timer/mc146818rtc.c
> +++ b/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,20 @@ static void rtc_get_time(RTCState *s, struct tm *tm)
>          rtc_from_bcd(s, s->cmos_data[RTC_CENTURY]) * 100 - 1900;
>  }
>  
> +static QLIST_HEAD(, RTCState) rtc_devices =
> +    QLIST_HEAD_INITIALIZER(rtc_devices);
> +
> +#ifdef TARGET_I386
> +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;
> @@ -910,6 +926,8 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
>      } else {
>          isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ);
>      }
> +    QLIST_INSERT_HEAD(&rtc_devices, s, link);
> +
>      return isadev;
>  }
>  
> diff --git a/monitor.c b/monitor.c
> index 8c17f89..f7a0206 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -5483,3 +5483,10 @@ QemuOptsList qemu_mon_opts = {
>          { /* end of list */ }
>      },
>  };
> +
> +#ifndef TARGET_I386
> +void qmp_rtc_reset_reinjection(Error **errp)
> +{
> +    error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
> +}
> +#endif
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index e4a1c80..17c09de 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -3661,3 +3661,26 @@ Example:
>                   { "slot": "3", "slot-type": "DIMM", "source": 0, "status": 0}
>     ]}
>  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 the RTC interrupt reinjection backlog.
> +
> +Arguments: None.
> +
> +Example:
> +
> +-> { "execute": "rtc-reset-reinjection" }
> +<- { "return": {} }
> +
> +EQMP

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command
  2014-06-25 19:51 ` Luiz Capitulino
@ 2014-06-26  5:59   ` Michael S. Tsirkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-06-26  5:59 UTC (permalink / raw)
  To: Luiz Capitulino
  Cc: Marcelo Tosatti, qemu-devel, Markus Armbruster, Stefan Hajnoczi,
	Andreas Färber

On Wed, Jun 25, 2014 at 03:51:30PM -0400, Luiz Capitulino wrote:
> On Wed, 25 Jun 2014 14:40:12 +0300
> "Michael S. Tsirkin" <mst@redhat.com> 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.
> > 
> > Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> Should this go via qmp tree or are you going to apply it to your tree?

It's applied in my tree.

> > ---
> > 
> > Marcelo, is this right?
> > 
> > Changes from v3:
> >     rebase on top of master
> >     fixes error code
> >     drop dead code
> > 
> >  qapi-schema.json       | 12 ++++++++++++
> >  hw/timer/mc146818rtc.c | 18 ++++++++++++++++++
> >  monitor.c              |  7 +++++++
> >  qmp-commands.hx        | 23 +++++++++++++++++++++++
> >  4 files changed, 60 insertions(+)
> > 
> > diff --git a/qapi-schema.json b/qapi-schema.json
> > index f490403..a282805 100644
> > --- a/qapi-schema.json
> > +++ b/qapi-schema.json
> > @@ -3288,3 +3288,15 @@
> >  # Since: 2.1
> >  ##
> >  { 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] }
> > +
> > +##
> > +# @rtc-reset-reinjection
> > +#
> > +# This command will reset the RTC interrupt reinjection backlog.
> > +# Can be used if another mechanism to synchronize guest time
> > +# is in effect, for example QEMU guest agent's guest-set-time
> > +# command.
> > +#
> > +# Since: 2.1
> > +##
> > +{ 'command': 'rtc-reset-reinjection' }
> > diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
> > index 1201f90..5bd8710 100644
> > --- a/hw/timer/mc146818rtc.c
> > +++ b/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,20 @@ static void rtc_get_time(RTCState *s, struct tm *tm)
> >          rtc_from_bcd(s, s->cmos_data[RTC_CENTURY]) * 100 - 1900;
> >  }
> >  
> > +static QLIST_HEAD(, RTCState) rtc_devices =
> > +    QLIST_HEAD_INITIALIZER(rtc_devices);
> > +
> > +#ifdef TARGET_I386
> > +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;
> > @@ -910,6 +926,8 @@ ISADevice *rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq)
> >      } else {
> >          isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ);
> >      }
> > +    QLIST_INSERT_HEAD(&rtc_devices, s, link);
> > +
> >      return isadev;
> >  }
> >  
> > diff --git a/monitor.c b/monitor.c
> > index 8c17f89..f7a0206 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -5483,3 +5483,10 @@ QemuOptsList qemu_mon_opts = {
> >          { /* end of list */ }
> >      },
> >  };
> > +
> > +#ifndef TARGET_I386
> > +void qmp_rtc_reset_reinjection(Error **errp)
> > +{
> > +    error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
> > +}
> > +#endif
> > diff --git a/qmp-commands.hx b/qmp-commands.hx
> > index e4a1c80..17c09de 100644
> > --- a/qmp-commands.hx
> > +++ b/qmp-commands.hx
> > @@ -3661,3 +3661,26 @@ Example:
> >                   { "slot": "3", "slot-type": "DIMM", "source": 0, "status": 0}
> >     ]}
> >  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 the RTC interrupt reinjection backlog.
> > +
> > +Arguments: None.
> > +
> > +Example:
> > +
> > +-> { "execute": "rtc-reset-reinjection" }
> > +<- { "return": {} }
> > +
> > +EQMP

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-26  5:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-25 11:40 [Qemu-devel] [PATCH v4] mc146818rtc: add rtc-reset-reinjection QMP command Michael S. Tsirkin
2014-06-25 13:58 ` Eric Blake
2014-06-25 15:18 ` Marcelo Tosatti
2014-06-25 19:51 ` Luiz Capitulino
2014-06-26  5:59   ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.