From patchwork Thu Feb 25 15:11:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 46247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0AB3DB7C33 for ; Fri, 26 Feb 2010 02:27:02 +1100 (EST) Received: from localhost ([127.0.0.1]:36641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nkfbb-0002gN-Ka for incoming@patchwork.ozlabs.org; Thu, 25 Feb 2010 10:26:23 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NkfNZ-0005HV-7t for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:11:53 -0500 Received: from [199.232.76.173] (port=42229 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkfNY-0005Gz-IB for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:11:52 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NkfNX-0000LC-7w for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:11:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46588) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NkfNW-0000L6-SS for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:11:51 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1PFBnvt029597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Feb 2010 10:11:50 -0500 Received: from localhost (vpn-9-86.rdu.redhat.com [10.11.9.86]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1PFBklm032348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 25 Feb 2010 10:11:48 -0500 Date: Thu, 25 Feb 2010 12:11:44 -0300 From: Luiz Capitulino To: qemu-devel@nongnu.org Message-ID: <20100225121144.10d30251@redhat.com> Organization: Red Hat Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH] QMP: Introduce RTC_CHANGE event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Emitted whenever the RTC time changes. Signed-off-by: Luiz Capitulino --- QMP/qmp-events.txt | 15 +++++++++++++++ hw/mc146818rtc.c | 2 ++ monitor.c | 3 +++ monitor.h | 1 + sysemu.h | 2 ++ vl.c | 9 +++++++++ 6 files changed, 32 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index b0183f9..f64b42d 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -38,6 +38,21 @@ Example: { "event": "RESET", "timestamp": { "seconds": 1267041653, "microseconds": 9518 } } +RTC_CHANGE +---------- + +Emitted when the RTC time changes. + +Data: + +- "offset": delta against the host UTC in seconds (json-number) + +Example: + +{ "event": "RTC_CHANGE", + "data": { "offset": 78 }, + "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } + SHUTDOWN -------- diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 2616d0d..a537855 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -297,6 +297,8 @@ static void rtc_set_time(RTCState *s) tm->tm_mday = rtc_from_bcd(s, s->cmos_data[RTC_DAY_OF_MONTH]); tm->tm_mon = rtc_from_bcd(s, s->cmos_data[RTC_MONTH]) - 1; tm->tm_year = rtc_from_bcd(s, s->cmos_data[RTC_YEAR]) + s->base_year - 1900; + + rtc_change_mon_event(tm); } static void rtc_copy_date(RTCState *s) diff --git a/monitor.c b/monitor.c index b2f5842..20512da 100644 --- a/monitor.c +++ b/monitor.c @@ -423,6 +423,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_BLOCK_IO_ERROR: event_name = "BLOCK_IO_ERROR"; break; + case QEVENT_RTC_CHANGE: + event_name = "RTC_CHANGE"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index 8cc21f5..aa51bd5 100644 --- a/monitor.h +++ b/monitor.h @@ -23,6 +23,7 @@ typedef enum MonitorEvent { QEVENT_VNC_INITIALIZED, QEVENT_VNC_DISCONNECTED, QEVENT_BLOCK_IO_ERROR, + QEVENT_RTC_CHANGE, QEVENT_MAX, } MonitorEvent; diff --git a/sysemu.h b/sysemu.h index 8ba618e..b5587f4 100644 --- a/sysemu.h +++ b/sysemu.h @@ -252,6 +252,8 @@ void do_usb_add(Monitor *mon, const QDict *qdict); void do_usb_del(Monitor *mon, const QDict *qdict); void usb_info(Monitor *mon); +void rtc_change_mon_event(struct tm *tm); + void register_devices(void); #endif diff --git a/vl.c b/vl.c index 3f580f5..6c05c93 100644 --- a/vl.c +++ b/vl.c @@ -1488,6 +1488,15 @@ int qemu_timedate_diff(struct tm *tm) return seconds - time(NULL); } +void rtc_change_mon_event(struct tm *tm) +{ + QObject *data; + + data = qobject_from_jsonf("{ 'offset': %d }", qemu_timedate_diff(tm)); + monitor_protocol_event(QEVENT_RTC_CHANGE, data); + qobject_decref(data); +} + static void configure_rtc_date_offset(const char *startdate, int legacy) { time_t rtc_start_date;