From patchwork Tue Jun 17 15:47:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 360555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8BC47140098 for ; Wed, 18 Jun 2014 01:48:44 +1000 (EST) Received: from localhost ([::1]:51482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwvco-0003aQ-HE for incoming@patchwork.ozlabs.org; Tue, 17 Jun 2014 11:48:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwvcP-0003Ji-0j for qemu-devel@nongnu.org; Tue, 17 Jun 2014 11:48:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwvcI-0006jj-Si for qemu-devel@nongnu.org; Tue, 17 Jun 2014 11:48:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwvcI-0006jV-K2 for qemu-devel@nongnu.org; Tue, 17 Jun 2014 11:48:10 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5HFm78o010161 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Jun 2014 11:48:07 -0400 Received: from amt.cnet (vpn1-6-105.gru2.redhat.com [10.97.6.105]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5HFm6P3032597; Tue, 17 Jun 2014 11:48:07 -0400 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id B45AD10038E; Tue, 17 Jun 2014 12:47:53 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id s5HFlqFD003977; Tue, 17 Jun 2014 12:47:52 -0300 Date: Tue, 17 Jun 2014 12:47:51 -0300 From: Marcelo Tosatti To: "Michael S. Tsirkin" Message-ID: <20140617154751.GA3947@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id s5HFm78o010161 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: gleb@kernel.org, mprivozn@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com Subject: [Qemu-devel] [PATCH v2] mc146818rtc: add rtc-reset-reinjection QMP command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index df54546..1782c4e 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; @@ -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/qapi-schema.json b/qapi-schema.json index 7bc33ea..a4e2c21 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -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' } diff --git a/qmp-commands.hx b/qmp-commands.hx index d8aa4ed..dc43789 100644 --- a/qmp-commands.hx +++ b/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 the RTC interrupt reinjection backlog. + +Arguments: None. + +Example: + +-> { "execute": "rtc-reset-reinjection" } +<- { "return": {} } + +EQMP