From: Wenchao Xia <wenchaoqemu@gmail.com>
To: qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com,
Wenchao Xia <wenchaoqemu@gmail.com>,
lcapitulino@redhat.com
Subject: [Qemu-devel] [RFC PATCH V3 5/5] qapi event: convert RTC_CHANGE
Date: Tue, 18 Mar 2014 22:16:41 -0700 [thread overview]
Message-ID: <1395206201-22999-6-git-send-email-wenchaoqemu@gmail.com> (raw)
In-Reply-To: <1395206201-22999-1-git-send-email-wenchaoqemu@gmail.com>
This is just an example of how to use qapi event API, and it
bypassed the event throttle queue. A complete convert should
be first define all events in qapi-schema.json, use qapi
event types in monitor functions, then change caller one
by one.
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
---
monitor.c | 15 +++++++++++++++
qapi-schema.json | 13 +++++++++++++
vl.c | 7 ++-----
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/monitor.c b/monitor.c
index 342e83b..163f654 100644
--- a/monitor.c
+++ b/monitor.c
@@ -57,6 +57,7 @@
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/json-parser.h"
+#include "qapi/qmp-event.h"
#include <qom/object_interfaces.h>
#include "qemu/osdep.h"
#include "cpu.h"
@@ -76,6 +77,8 @@
#endif
#include "hw/lm32/lm32_pic.h"
+#include "qapi-event.h"
+
//#define DEBUG
//#define DEBUG_COMPLETION
@@ -632,6 +635,16 @@ monitor_protocol_event_throttle(MonitorEvent event,
evstate->data = NULL;
}
+static void monitor_event_emit(int event_kind, QDict *d, Error **errp)
+{
+ Monitor *mon;
+
+ QLIST_FOREACH(mon, &mon_list, entry) {
+ if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {
+ monitor_json_emitter(mon, QOBJECT(d));
+ }
+ }
+}
/* Global, one-time initializer to configure the rate limiting
* and initialize state */
@@ -644,6 +657,8 @@ static void monitor_protocol_event_init(void)
/* limit the rate of quorum events to avoid hammering the management */
monitor_protocol_event_throttle(QEVENT_QUORUM_REPORT_BAD, 1000);
monitor_protocol_event_throttle(QEVENT_QUORUM_FAILURE, 1000);
+
+ qmp_event_set_func_emit(monitor_event_emit);
}
/**
diff --git a/qapi-schema.json b/qapi-schema.json
index b68cd44..62918c5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4686,3 +4686,16 @@
'btn' : 'InputBtnEvent',
'rel' : 'InputMoveEvent',
'abs' : 'InputMoveEvent' } }
+
+##
+# @RTC_CHANGE
+#
+# Emitted when the guest changes the RTC time.
+#
+# @offset: Offset between base RTC clock (as specified by -rtc base), and
+# new RTC clock value
+#
+# Since: 2.1
+##
+{ 'event': 'RTC_CHANGE',
+ 'data': { 'offset' : 'int' } }
diff --git a/vl.c b/vl.c
index f0fe48b..08a0e56 100644
--- a/vl.c
+++ b/vl.c
@@ -117,6 +117,7 @@ int main(int argc, char **argv)
#include "ui/qemu-spice.h"
#include "qapi/string-input-visitor.h"
#include "qom/object_interfaces.h"
+#include "qapi-event.h"
#define DEFAULT_RAM_SIZE 128
@@ -723,11 +724,7 @@ int qemu_timedate_diff(struct tm *tm)
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);
+ qapi_event_send_rtc_change(qemu_timedate_diff(tm), NULL);
}
static void configure_rtc_date_offset(const char *startdate, int legacy)
--
1.7.1
next prev parent reply other threads:[~2014-03-19 5:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-19 5:16 [Qemu-devel] [RFC PATCH V3 0/5] add direct support of event in qapi schema Wenchao Xia
2014-03-19 5:16 ` [Qemu-devel] [RFC PATCH V3 1/5] os-posix: include sys/time.h Wenchao Xia
2014-03-19 5:16 ` [Qemu-devel] [RFC PATCH V3 2/5] qapi: add event helper functions Wenchao Xia
2014-03-20 22:53 ` Eric Blake
2014-03-24 0:53 ` Wenchao Xia
2014-03-24 13:11 ` Eric Blake
2014-03-19 5:16 ` [Qemu-devel] [RFC PATCH V3 3/5] qapi script: add event support Wenchao Xia
2014-03-20 23:06 ` Eric Blake
2014-03-24 0:59 ` Wenchao Xia
2014-03-19 5:16 ` [Qemu-devel] [RFC PATCH V3 4/5] test: add test cases for qapi event Wenchao Xia
2014-03-21 0:23 ` Eric Blake
2014-03-24 1:01 ` Wenchao Xia
2014-03-19 5:16 ` Wenchao Xia [this message]
2014-03-21 0:25 ` [Qemu-devel] [RFC PATCH V3 5/5] qapi event: convert RTC_CHANGE Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395206201-22999-6-git-send-email-wenchaoqemu@gmail.com \
--to=wenchaoqemu@gmail.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).