From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Wenchao Xia <xiawenc@linux.vnet.ibm.com>,
mreitz@redhat.com, armbru@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [RFC PATCH V2 5/5] qapi event: convert RTC_CHANGE
Date: Fri, 3 Jan 2014 07:10:34 +0800 [thread overview]
Message-ID: <1388704234-22498-6-git-send-email-xiawenc@linux.vnet.ibm.com> (raw)
In-Reply-To: <1388704234-22498-1-git-send-email-xiawenc@linux.vnet.ibm.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 calller one
by one.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
monitor.c | 14 ++++++++++++++
qapi-schema.json | 3 +++
vl.c | 7 ++-----
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/monitor.c b/monitor.c
index 845f608..8dca027 100644
--- a/monitor.c
+++ b/monitor.c
@@ -74,6 +74,8 @@
#endif
#include "hw/lm32/lm32_pic.h"
+#include "qapi-event.h"
+
//#define DEBUG
//#define DEBUG_COMPLETION
@@ -628,6 +630,16 @@ monitor_protocol_event_throttle(MonitorEvent event,
evstate->data = NULL;
}
+static void monitor_event_emit(QAPIEvent ev, 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 */
@@ -637,6 +649,8 @@ static void monitor_protocol_event_init(void)
monitor_protocol_event_throttle(QEVENT_RTC_CHANGE, 1000);
monitor_protocol_event_throttle(QEVENT_BALLOON_CHANGE, 1000);
monitor_protocol_event_throttle(QEVENT_WATCHDOG, 1000);
+
+ qapi_event_set_func_emit(monitor_event_emit);
}
/**
diff --git a/qapi-schema.json b/qapi-schema.json
index 9b51dcc..60ddf44 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4247,3 +4247,6 @@
# Since: 1.7
##
{ 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
+
+{ 'event': 'RTC_CHANGE',
+ 'data': { 'offset' : 'int' } }
diff --git a/vl.c b/vl.c
index 7511e70..7726116 100644
--- a/vl.c
+++ b/vl.c
@@ -170,6 +170,7 @@ int main(int argc, char **argv)
#include "ui/qemu-spice.h"
#include "qapi/string-input-visitor.h"
+#include "qapi-event.h"
//#define DEBUG_NET
//#define DEBUG_SLIRP
@@ -743,11 +744,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-01-03 7:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-02 23:10 [Qemu-devel] [RFC PATCH V2 0/5] add direct support of event in qapi schema Wenchao Xia
2014-01-02 23:10 ` [Qemu-devel] [RFC PATCH V2 1/5] os-posix: include sys/time.h Wenchao Xia
2014-01-02 23:10 ` [Qemu-devel] [RFC PATCH V2 2/5] qapi: add event helper functions Wenchao Xia
2014-01-06 22:23 ` Luiz Capitulino
2014-01-07 2:28 ` Wenchao Xia
2014-03-06 18:26 ` Eric Blake
2014-01-02 23:10 ` [Qemu-devel] [RFC PATCH V2 3/5] qapi script: add event support by qapi-event.py Wenchao Xia
2014-01-06 23:10 ` Luiz Capitulino
2014-01-06 23:17 ` Luiz Capitulino
2014-01-07 3:24 ` Wenchao Xia
2014-02-14 3:26 ` Wenchao Xia
2014-01-07 2:53 ` Wenchao Xia
2014-03-06 18:49 ` Eric Blake
2014-03-19 2:38 ` Wenchao Xia
2014-03-20 22:29 ` Eric Blake
2014-03-24 0:55 ` Wenchao Xia
2014-03-26 12:42 ` Markus Armbruster
2014-03-26 13:13 ` Benoît Canet
2014-03-27 7:52 ` Wenchao Xia
2014-01-02 23:10 ` [Qemu-devel] [RFC PATCH V2 4/5] test: add test cases for qapi event Wenchao Xia
2014-03-06 20:05 ` Eric Blake
2014-01-02 23:10 ` Wenchao Xia [this message]
2014-03-06 20:24 ` [Qemu-devel] [RFC PATCH V2 5/5] qapi event: convert RTC_CHANGE Eric Blake
2014-01-06 23:18 ` [Qemu-devel] [RFC PATCH V2 0/5] add direct support of event in qapi schema Luiz Capitulino
2014-03-06 18:14 ` Eric Blake
2014-03-06 19:58 ` Luiz Capitulino
2014-03-07 1:13 ` Wenchao Xia
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=1388704234-22498-6-git-send-email-xiawenc@linux.vnet.ibm.com \
--to=xiawenc@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mreitz@redhat.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).