From patchwork Fri Apr 26 19:43:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 240027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CF3E72C0106 for ; Sat, 27 Apr 2013 05:44:30 +1000 (EST) Received: from localhost ([::1]:46199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVoZJ-0000KF-35 for incoming@patchwork.ozlabs.org; Fri, 26 Apr 2013 15:44:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVoYl-0000El-C1 for qemu-devel@nongnu.org; Fri, 26 Apr 2013 15:43:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVoYh-0006ka-Hj for qemu-devel@nongnu.org; Fri, 26 Apr 2013 15:43:55 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:45961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVoYg-0006kI-Tj for qemu-devel@nongnu.org; Fri, 26 Apr 2013 15:43:51 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 27 Apr 2013 05:35:53 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 27 Apr 2013 05:35:49 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 59E93357804E for ; Sat, 27 Apr 2013 05:43:45 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3QJU7rm18153518 for ; Sat, 27 Apr 2013 05:30:07 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3QJhiEE004726 for ; Sat, 27 Apr 2013 05:43:44 +1000 Received: from titi.austin.rr.com (sig-9-65-136-227.mts.ibm.com [9.65.136.227]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3QJhL74004344; Sat, 27 Apr 2013 05:43:25 +1000 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Fri, 26 Apr 2013 14:43:06 -0500 Message-Id: <1367005387-330-3-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1367005387-330-1-git-send-email-aliguori@us.ibm.com> References: <1367005387-330-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13042619-5490-0000-0000-0000035AD375 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.144 Cc: Kevin Wolf , Anthony Liguori Subject: [Qemu-devel] [PATCH 2/3] monitor: add notifier list for monitor events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This lets us register for events internally within QEMU. Signed-off-by: Anthony Liguori --- 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 + * + * 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);