From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1IQY-000678-QC for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1IQS-0002sX-IW for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:58:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1IQS-0002rR-AM for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:58:00 -0400 Date: Sun, 29 Jun 2014 19:58:21 +0300 From: "Michael S. Tsirkin" Message-ID: <1404060115-27410-7-git-send-email-mst@redhat.com> References: <1404060115-27410-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1404060115-27410-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 06/37] 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: Peter Maydell , Stefan Hajnoczi , Marcelo Tosatti , Markus Armbruster , Luiz Capitulino , Anthony Liguori , Paolo Bonzini From: Marcelo Tosatti 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 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 a83befc..b11aad2 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3468,3 +3468,15 @@ ## { 'enum': 'GuestPanicAction', 'data': [ 'pause' ] } + +## +# @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 05002bf..307732c 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -27,6 +27,7 @@ #include "hw/timer/mc146818rtc.h" #include "qapi/visitor.h" #include "qapi-event.h" +#include "qmp-commands.h" #ifdef TARGET_I386 #include "hw/i386/apic.h" @@ -85,6 +86,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); @@ -523,6 +525,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; @@ -911,6 +927,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 5718d0b..799131b 100644 --- a/monitor.c +++ b/monitor.c @@ -5441,3 +5441,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 65218bc..1ea18b2 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3675,3 +3675,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