summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2010-02-25 12:11:44 -0300
committerAnthony Liguori <aliguori@us.ibm.com>2010-03-08 11:30:09 -0600
commit80cd34787fc0fc31b1a341c7b8d8e729c1b6ea58 (patch)
tree87b4d9bb87753831af21d16f6ce011f985fdbd37
parentd74c7dfd1b63850309d7595b4db2e91b78c1dc05 (diff)
QMP: Introduce RTC_CHANGE event
Emitted whenever the RTC time changes. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--QMP/qmp-events.txt15
-rw-r--r--hw/mc146818rtc.c2
-rw-r--r--monitor.c3
-rw-r--r--monitor.h1
-rw-r--r--sysemu.h2
-rw-r--r--vl.c9
6 files changed, 32 insertions, 0 deletions
diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
index 5ab575065..72920f6df 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 2616d0d7e..a53785593 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 1ef672c10..f062b9249 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 8cc21f53f..aa51bd5a0 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 d77344c1b..afa11b551 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -256,6 +256,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 03a47a437..d8328c71d 100644
--- a/vl.c
+++ b/vl.c
@@ -1492,6 +1492,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;