From: "Michael S. Tsirkin" <mst@redhat.com>
To: mtosatti@redhat.com
Cc: gleb@kernel.org, mprivozn@redhat.com, pbonzini@redhat.com,
qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [patch 1/3] mc146818rtc: add rtc-reset-reinjection QMP command
Date: Tue, 17 Jun 2014 15:32:32 +0300 [thread overview]
Message-ID: <20140617123232.GA5708@redhat.com> (raw)
In-Reply-To: <20140604175446.411400387@amt.cnet>
On Wed, Jun 04, 2014 at 02:52:01PM -0300, mtosatti@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>
>
> ---
> hw/timer/mc146818rtc.c | 22 ++++++++++++++++++++++
> qapi-schema.json | 12 ++++++++++++
> qmp-commands.hx | 23 +++++++++++++++++++++++
> 3 files changed, 57 insertions(+)
>
> Index: qemu/hw/timer/mc146818rtc.c
> ===================================================================
> --- qemu.orig/hw/timer/mc146818rtc.c 2014-06-02 23:14:09.570443599 -0300
> +++ qemu/hw/timer/mc146818rtc.c 2014-06-02 23:14:11.707436729 -0300
> @@ -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 @@
> Notifier clock_reset_notifier;
> LostTickPolicy lost_tick_policy;
> Notifier suspend_notifier;
> +#ifdef TARGET_I386
> + QLIST_ENTRY(RTCState) link;
> +#endif
Could we avoid these ifdefs?
I'd rather maintain the link unconditionally,
even if it's unused except on x86.
> } RTCState;
>
> static void rtc_set_time(RTCState *s);
> @@ -522,6 +526,20 @@
> 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 @@
> } else {
> isa_init_irq(isadev, &s->irq, RTC_ISA_IRQ);
> }
> +#ifdef TARGET_I386
> + QLIST_INSERT_HEAD(&rtc_devices, s, link);
> +#endif
> +
> return isadev;
> }
>
> Index: qemu/qapi-schema.json
> ===================================================================
> --- qemu.orig/qapi-schema.json 2014-06-02 23:14:09.570443599 -0300
> +++ qemu/qapi-schema.json 2014-06-02 23:14:11.709436722 -0300
> @@ -4722,3 +4722,15 @@
> 'btn' : 'InputBtnEvent',
> 'rel' : 'InputMoveEvent',
> 'abs' : 'InputMoveEvent' } }
> +
> +##
> +# @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' }
> Index: qemu/qmp-commands.hx
> ===================================================================
> --- qemu.orig/qmp-commands.hx 2014-06-02 23:14:09.570443599 -0300
> +++ qemu/qmp-commands.hx 2014-06-02 23:14:11.710436719 -0300
> @@ -3572,3 +3572,26 @@
> } } ] }
>
> 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
>
>
next prev parent reply other threads:[~2014-06-17 12:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-04 17:52 [Qemu-devel] [patch 0/3] add QMP command to reset rtc interrupt backlog (v4) mtosatti
2014-06-04 17:52 ` [Qemu-devel] [patch 1/3] mc146818rtc: add rtc-reset-reinjection QMP command mtosatti
2014-06-17 12:32 ` Michael S. Tsirkin [this message]
2014-06-17 13:12 ` Eric Blake
2014-06-04 17:52 ` [Qemu-devel] [patch 2/3] add object_property_add_alias mtosatti
2014-06-05 11:09 ` Paolo Bonzini
2014-06-04 17:52 ` [Qemu-devel] [patch 3/3] mc146818rtc: add "rtc" link to "/machine" mtosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140617123232.GA5708@redhat.com \
--to=mst@redhat.com \
--cc=armbru@redhat.com \
--cc=gleb@kernel.org \
--cc=mprivozn@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).