From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wfibm-0001Lg-Sx for qemu-devel@nongnu.org; Thu, 01 May 2014 00:28:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wfibd-0002Mv-Pi for qemu-devel@nongnu.org; Thu, 01 May 2014 00:28:30 -0400 Received: from mail-ie0-x234.google.com ([2607:f8b0:4001:c03::234]:45708) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wfibd-0002Me-L0 for qemu-devel@nongnu.org; Thu, 01 May 2014 00:28:21 -0400 Received: by mail-ie0-f180.google.com with SMTP id as1so3008871iec.25 for ; Wed, 30 Apr 2014 21:28:21 -0700 (PDT) From: Wenchao Xia Date: Wed, 30 Apr 2014 21:26:50 -0700 Message-Id: <1398918422-3019-17-git-send-email-wenchaoqemu@gmail.com> In-Reply-To: <1398918422-3019-1-git-send-email-wenchaoqemu@gmail.com> References: <1398918422-3019-1-git-send-email-wenchaoqemu@gmail.com> Subject: [Qemu-devel] [PATCH V5 16/28] qapi event: convert WATCHDOG List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com, Wenchao Xia , lcapitulino@redhat.com Signed-off-by: Wenchao Xia --- hw/watchdog/watchdog.c | 23 +++++++---------------- 1 files changed, 7 insertions(+), 16 deletions(-) diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c index f28161b..9284d3f 100644 --- a/hw/watchdog/watchdog.c +++ b/hw/watchdog/watchdog.c @@ -24,9 +24,9 @@ #include "qemu/config-file.h" #include "qemu/queue.h" #include "qapi/qmp/types.h" -#include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "sysemu/watchdog.h" +#include "qapi-event.h" /* Possible values for action parameter. */ #define WDT_RESET 1 /* Hard reset. */ @@ -101,15 +101,6 @@ int select_watchdog_action(const char *p) return 0; } -static void watchdog_mon_event(const char *action) -{ - QObject *data; - - data = qobject_from_jsonf("{ 'action': %s }", action); - monitor_protocol_event(QEVENT_WATCHDOG, data); - qobject_decref(data); -} - /* This actually performs the "action" once a watchdog has expired, * ie. reboot, shutdown, exit, etc. */ @@ -117,31 +108,31 @@ void watchdog_perform_action(void) { switch(watchdog_action) { case WDT_RESET: /* same as 'system_reset' in monitor */ - watchdog_mon_event("reset"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, NULL); qemu_system_reset_request(); break; case WDT_SHUTDOWN: /* same as 'system_powerdown' in monitor */ - watchdog_mon_event("shutdown"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, NULL); qemu_system_powerdown_request(); break; case WDT_POWEROFF: /* same as 'quit' command in monitor */ - watchdog_mon_event("poweroff"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, NULL); exit(0); case WDT_PAUSE: /* same as 'stop' command in monitor */ - watchdog_mon_event("pause"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, NULL); vm_stop(RUN_STATE_WATCHDOG); break; case WDT_DEBUG: - watchdog_mon_event("debug"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, NULL); fprintf(stderr, "watchdog: timer fired\n"); break; case WDT_NONE: - watchdog_mon_event("none"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, NULL); break; } } -- 1.7.1