@@ -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);
}
/**
@@ -4247,3 +4247,6 @@
# Since: 1.7
##
{ 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
+
+{ 'event': 'RTC_CHANGE',
+ 'data': { 'offset' : 'int' } }
@@ -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)
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(-)