diff options
author | Luiz Capitulino | 2010-02-25 16:13:04 +0100 |
---|---|---|
committer | Anthony Liguori | 2010-03-09 15:47:27 +0100 |
commit | 9eedeb3b88173d84d438557cada237346a764e0b (patch) | |
tree | f5f276c6cc5e8196da7090256da72661e3fb85e0 /hw/watchdog.c | |
parent | Restore terminal attributes for tty based monitor (diff) | |
download | qemu-9eedeb3b88173d84d438557cada237346a764e0b.tar.gz qemu-9eedeb3b88173d84d438557cada237346a764e0b.tar.xz qemu-9eedeb3b88173d84d438557cada237346a764e0b.zip |
QMP: Introduce WATCHDOG event
It's emitted whenever the watchdog device's timer expires. The action
taken is provided in the 'data' member.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/watchdog.c')
-rw-r--r-- | hw/watchdog.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/hw/watchdog.c b/hw/watchdog.c index 6a3d1b4320..aebb08a0ee 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; } } |