From patchwork Thu Feb 25 15:13:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 46248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D85A8B6F11 for ; Fri, 26 Feb 2010 02:29:42 +1100 (EST) Received: from localhost ([127.0.0.1]:38011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nkfdj-0004cr-NQ for incoming@patchwork.ozlabs.org; Thu, 25 Feb 2010 10:28:35 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NkfOw-0005q3-6B for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:13:18 -0500 Received: from [199.232.76.173] (port=42232 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkfOu-0005pF-Ru for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:13:16 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NkfOt-0000Sm-9s for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:13:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46326) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NkfOs-0000SU-Rq for qemu-devel@nongnu.org; Thu, 25 Feb 2010 10:13:15 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1PFDABt031237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Feb 2010 10:13:10 -0500 Received: from localhost (vpn-9-86.rdu.redhat.com [10.11.9.86]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1PFD6OM006329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 25 Feb 2010 10:13:09 -0500 Date: Thu, 25 Feb 2010 12:13:04 -0300 From: Luiz Capitulino To: qemu-devel@nongnu.org Message-ID: <20100225121304.7992a7b5@redhat.com> Organization: Red Hat Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: rjones@redhat.com Subject: [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It's emitted whenever the watchdog device's timer expires. The action taken is provided in the 'data' member. Signed-off-by: Luiz Capitulino --- QMP/qmp-events.txt | 19 +++++++++++++++++++ hw/watchdog.c | 17 +++++++++++++++++ monitor.c | 3 +++ monitor.h | 1 + 4 files changed, 40 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 72920f6..a94e9b4 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -169,3 +169,22 @@ Example: "client": { "family": "ipv4", "service": "46089", "host": "127.0.0.1", "sasl_username": "luiz" } }, "timestamp": { "seconds": 1263475302, "microseconds": 150772 } } + +WATCHDOG +-------- + +Emitted when the watchdog device's timer is expired. + +Data: + +- "action": Action that has been taken, it's one of the following (json-string): + "reset", "shutdown", "poweroff", "pause", "debug", or "none" + +Example: + +{ "event": "WATCHDOG", + "data": { "action": "reset" }, + "timestamp": { "seconds": 1267061043, "microseconds": 959568 } } + +Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is +followed respectively by the RESET, SHUTDOWN, or STOP events. diff --git a/hw/watchdog.c b/hw/watchdog.c index 6a3d1b4..aebb08a 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -23,6 +23,8 @@ #include "qemu-option.h" #include "qemu-config.h" #include "qemu-queue.h" +#include "qemu-objects.h" +#include "monitor.h" #include "sysemu.h" #include "hw/watchdog.h" @@ -98,6 +100,15 @@ 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. */ @@ -105,26 +116,32 @@ void watchdog_perform_action(void) { switch(watchdog_action) { case WDT_RESET: /* same as 'system_reset' in monitor */ + watchdog_mon_event("reset"); qemu_system_reset_request(); break; case WDT_SHUTDOWN: /* same as 'system_powerdown' in monitor */ + watchdog_mon_event("shutdown"); qemu_system_powerdown_request(); break; case WDT_POWEROFF: /* same as 'quit' command in monitor */ + watchdog_mon_event("poweroff"); exit(0); break; case WDT_PAUSE: /* same as 'stop' command in monitor */ + watchdog_mon_event("pause"); vm_stop(0); break; case WDT_DEBUG: + watchdog_mon_event("debug"); fprintf(stderr, "watchdog: timer fired\n"); break; case WDT_NONE: + watchdog_mon_event("none"); break; } } diff --git a/monitor.c b/monitor.c index 20512da..4704b18 100644 --- a/monitor.c +++ b/monitor.c @@ -426,6 +426,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_RTC_CHANGE: event_name = "RTC_CHANGE"; break; + case QEVENT_WATCHDOG: + event_name = "WATCHDOG"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index aa51bd5..e5f2d2b 100644 --- a/monitor.h +++ b/monitor.h @@ -24,6 +24,7 @@ typedef enum MonitorEvent { QEVENT_VNC_DISCONNECTED, QEVENT_BLOCK_IO_ERROR, QEVENT_RTC_CHANGE, + QEVENT_WATCHDOG, QEVENT_MAX, } MonitorEvent;