From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwsYh-0008Dz-VN for qemu-devel@nongnu.org; Tue, 17 Jun 2014 08:32:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwsYa-0006kW-G8 for qemu-devel@nongnu.org; Tue, 17 Jun 2014 08:32:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23934) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwsYa-0006kM-7u for qemu-devel@nongnu.org; Tue, 17 Jun 2014 08:32:08 -0400 Date: Tue, 17 Jun 2014 15:32:32 +0300 From: "Michael S. Tsirkin" Message-ID: <20140617123232.GA5708@redhat.com> References: <20140604175200.667995104@amt.cnet> <20140604175446.411400387@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20140604175446.411400387@amt.cnet> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [patch 1/3] mc146818rtc: add rtc-reset-reinjection QMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mtosatti@redhat.com Cc: gleb@kernel.org, mprivozn@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com 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=20 > QGA's guest-set-time command. >=20 > Failing to do so causes both corrections to be applied (summed), > resulting in an incorrect guest time. >=20 > Signed-off-by: Marcelo Tosatti >=20 > --- > hw/timer/mc146818rtc.c | 22 ++++++++++++++++++++++ > qapi-schema.json | 12 ++++++++++++ > qmp-commands.hx | 23 +++++++++++++++++++++++ > 3 files changed, 57 insertions(+) >=20 > Index: qemu/hw/timer/mc146818rtc.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu.orig/hw/timer/mc146818rtc.c 2014-06-02 23:14:09.570443599 -030= 0 > +++ 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" > =20 > #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; > =20 > static void rtc_set_time(RTCState *s); > @@ -522,6 +526,20 @@ > rtc_from_bcd(s, s->cmos_data[RTC_CENTURY]) * 100 - 1900; > } > =20 > +#ifdef TARGET_I386 > +static QLIST_HEAD(, RTCState) rtc_devices =3D > + QLIST_HEAD_INITIALIZER(rtc_devices); > + > +void qmp_rtc_reset_reinjection(Error **errp) > +{ > + RTCState *s; > + > + QLIST_FOREACH(s, &rtc_devices, link) { > + s->irq_coalesced =3D 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; > } > =20 > Index: qemu/qapi-schema.json > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- 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 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- 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 @@ > } }=A0] } > =20 > EQMP > + > +#if defined (TARGET_I386) > + { > + .name =3D "rtc-reset-reinjection", > + .args_type =3D "", > + .mhandler.cmd_new =3D 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 >=20 >=20