From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 2/3] monitor: add notifier list for monitor events
Date: Fri, 26 Apr 2013 14:43:06 -0500 [thread overview]
Message-ID: <1367005387-330-3-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1367005387-330-1-git-send-email-aliguori@us.ibm.com>
This lets us register for events internally within QEMU.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
include/qapi/qmp/qevents.h | 21 +++++++++++++++++++++
monitor.c | 15 +++++++++++++++
2 files changed, 36 insertions(+)
create mode 100644 include/qapi/qmp/qevents.h
diff --git a/include/qapi/qmp/qevents.h b/include/qapi/qmp/qevents.h
new file mode 100644
index 0000000..2a91fd0
--- /dev/null
+++ b/include/qapi/qmp/qevents.h
@@ -0,0 +1,21 @@
+/*
+ * QEvent Support
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QMP_EVENTS_H
+#define QMP_EVENTS_H
+
+#include "qemu/notify.h"
+
+void qmp_add_event_notifier(Notifier *notifier);
+void qmp_del_event_notifier(Notifier *notifier);
+
+#endif
diff --git a/monitor.c b/monitor.c
index 332abe7..5168ea5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -56,6 +56,7 @@
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/json-parser.h"
+#include "qapi/qmp/qevents.h"
#include "qemu/osdep.h"
#include "cpu.h"
#include "trace.h"
@@ -502,6 +503,19 @@ QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
MonitorEventState monitor_event_state[QEVENT_MAX];
QemuMutex monitor_event_state_lock;
+static NotifierList qmp_event_notifier_list =
+ NOTIFIER_LIST_INITIALIZER(qmp_event_notifier_list);
+
+void qmp_add_event_notifier(Notifier *notifier)
+{
+ notifier_list_add(&qmp_event_notifier_list, notifier);
+}
+
+void qmp_del_event_notifier(Notifier *notifier)
+{
+ notifier_remove(notifier);
+}
+
/*
* Emits the event to every monitor instance
*/
@@ -512,6 +526,7 @@ monitor_protocol_event_emit(MonitorEvent event,
Monitor *mon;
trace_monitor_protocol_event_emit(event, data);
+ notifier_list_notify(&qmp_event_notifier_list, data);
QLIST_FOREACH(mon, &mon_list, entry) {
if (monitor_ctrl_mode(mon) && qmp_cmd_mode(mon)) {
monitor_json_emitter(mon, data);
--
1.8.0
next prev parent reply other threads:[~2013-04-26 19:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 19:43 [Qemu-devel] [PATCH 0/3] gtk: add Devices menu Anthony Liguori
2013-04-26 19:43 ` [Qemu-devel] [PATCH 1/3] ide: add drive-id property Anthony Liguori
2013-05-02 10:05 ` Andreas Färber
2013-05-02 12:59 ` Anthony Liguori
2013-04-26 19:43 ` Anthony Liguori [this message]
2013-04-26 19:43 ` [Qemu-devel] [PATCH 3/3] gtk: add devices menu to allow changing removable block devices Anthony Liguori
2013-05-02 8:49 ` Kevin Wolf
2013-05-02 13:41 ` Anthony Liguori
2013-05-02 13:53 ` Luiz Capitulino
2013-05-02 14:06 ` Kevin Wolf
2013-05-02 15:29 ` Markus Armbruster
2013-05-02 15:40 ` Anthony Liguori
2013-05-03 12:31 ` [Qemu-devel] [libvirt] " Daniel P. Berrange
2013-05-03 13:52 ` Anthony Liguori
2013-05-03 13:57 ` Daniel P. Berrange
2013-05-02 15:47 ` [Qemu-devel] " Anthony Liguori
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=1367005387-330-3-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=kwolf@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).