* [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event
@ 2010-02-25 15:13 Luiz Capitulino
2010-02-25 15:21 ` [Qemu-devel] " Richard W.M. Jones
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Luiz Capitulino @ 2010-02-25 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: rjones
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>
---
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;
--
1.7.0.GIT
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH] QMP: Introduce WATCHDOG event
2010-02-25 15:13 [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event Luiz Capitulino
@ 2010-02-25 15:21 ` Richard W.M. Jones
2010-02-26 10:58 ` [Qemu-devel] " Daniel P. Berrange
2010-03-09 15:01 ` Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Richard W.M. Jones @ 2010-02-25 15:21 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel
On Thu, Feb 25, 2010 at 12:13:04PM -0300, Luiz Capitulino wrote:
>
> It's emitted whenever the watchdog device's timer expires. The action
> taken is provided in the 'data' member.
Patch looks good to me - ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event
2010-02-25 15:13 [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event Luiz Capitulino
2010-02-25 15:21 ` [Qemu-devel] " Richard W.M. Jones
@ 2010-02-26 10:58 ` Daniel P. Berrange
2010-03-09 15:01 ` Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Daniel P. Berrange @ 2010-02-26 10:58 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel, rjones
On Thu, Feb 25, 2010 at 12:13:04PM -0300, Luiz Capitulino wrote:
>
> 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>
> ---
> 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.
Ok, this should be sufficient for libvirt's needs
Regards,
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event
2010-02-25 15:13 [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event Luiz Capitulino
2010-02-25 15:21 ` [Qemu-devel] " Richard W.M. Jones
2010-02-26 10:58 ` [Qemu-devel] " Daniel P. Berrange
@ 2010-03-09 15:01 ` Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2010-03-09 15:01 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: qemu-devel, rjones
On 02/25/2010 09:13 AM, Luiz Capitulino wrote:
> 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>
>
Applied. Thanks.
Regards,
Anthony Liguori
>
---
> 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;
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-09 15:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-25 15:13 [Qemu-devel] [PATCH] QMP: Introduce WATCHDOG event Luiz Capitulino
2010-02-25 15:21 ` [Qemu-devel] " Richard W.M. Jones
2010-02-26 10:58 ` [Qemu-devel] " Daniel P. Berrange
2010-03-09 15:01 ` Anthony Liguori
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.