From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrWSu-0002lJ-Lb for qemu-devel@nongnu.org; Mon, 02 Jun 2014 13:56:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrWSm-0003Aj-8n for qemu-devel@nongnu.org; Mon, 02 Jun 2014 13:56:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7171) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrWSm-0003Ab-0s for qemu-devel@nongnu.org; Mon, 02 Jun 2014 13:56:00 -0400 Message-Id: <20140602175345.235004414@amt.cnet> Date: Mon, 02 Jun 2014 14:51:05 -0300 From: mtosatti@redhat.com References: <20140530201145.194061806@amt.cnet> <20140602175104.579823673@amt.cnet> Content-Disposition: inline; filename=rtc-reset Subject: [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: qemu-devel@nongnu.org Cc: gleb@kernel.org, mprivozn@redhat.com, Marcelo Tosatti , armbru@redhat.com, pbonzini@redhat.com 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 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,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; } 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 (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