diff mbox series

[v4,3/3] watchdog: Allow setting action on the fly

Message ID 6f78df0d8af98d89bdae1d189c0e21ba7ca3ead9.1504696921.git.mprivozn@redhat.com
State New
Headers show
Series watchdog: Allow setting action on the fly | expand

Commit Message

Michal Prívozník Sept. 6, 2017, 11:24 a.m. UTC
Currently, the only time that users can set watchdog action is at
the start as all we expose is this -watchdog-action command line
argument. This is suboptimal when users want to plug the device
later via monitor. Alternatively, they might want to change the
action for already existing device on the fly.

Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1447169

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 hw/watchdog/watchdog.c | 8 +++++++-
 qapi-schema.json       | 9 +++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

Comments

Eric Blake Sept. 6, 2017, 3:39 p.m. UTC | #1
On 09/06/2017 06:24 AM, Michal Privoznik wrote:
> Currently, the only time that users can set watchdog action is at
> the start as all we expose is this -watchdog-action command line
> argument. This is suboptimal when users want to plug the device
> later via monitor. Alternatively, they might want to change the
> action for already existing device on the fly.
> 
> Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1447169
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  hw/watchdog/watchdog.c | 8 +++++++-
>  qapi-schema.json       | 9 +++++++++
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 

> +++ b/qapi-schema.json
> @@ -3143,3 +3143,12 @@
>  # Since 2.9
>  ##
>  { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
> +
> +##
> +# @watchdog-set-action:
> +#
> +# Set watchdog action
> +#
> +# Since 2.11
> +##
> +{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} }

Markus went to some effort to sort the documentation output; is plopping
this at the end of the file the best location?

Otherwise,
Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster Sept. 6, 2017, 5:15 p.m. UTC | #2
Eric Blake <eblake@redhat.com> writes:

> On 09/06/2017 06:24 AM, Michal Privoznik wrote:
>> Currently, the only time that users can set watchdog action is at
>> the start as all we expose is this -watchdog-action command line
>> argument. This is suboptimal when users want to plug the device
>> later via monitor. Alternatively, they might want to change the
>> action for already existing device on the fly.
>> 
>> Inspired by: https://bugzilla.redhat.com/show_bug.cgi?id=1447169
>> 
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>> ---
>>  hw/watchdog/watchdog.c | 8 +++++++-
>>  qapi-schema.json       | 9 +++++++++
>>  2 files changed, 16 insertions(+), 1 deletion(-)
>> 
>
>> +++ b/qapi-schema.json
>> @@ -3143,3 +3143,12 @@
>>  # Since 2.9
>>  ##
>>  { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
>> +
>> +##
>> +# @watchdog-set-action:
>> +#
>> +# Set watchdog action
>> +#
>> +# Since 2.11
>> +##
>> +{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} }
>
> Markus went to some effort to sort the documentation output; is plopping
> this at the end of the file the best location?

This patch won't regress any of my work, as I only moved stuff out of
qapi-schema-json, I didn't reorder within.

> Otherwise,
> Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 547a49a1e4..c49a069cbc 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -29,6 +29,7 @@ 
 #include "qapi-event.h"
 #include "hw/nmi.h"
 #include "qemu/help_option.h"
+#include "qmp-commands.h"
 
 static WatchdogAction watchdog_action = WATCHDOG_ACTION_RESET;
 static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
@@ -82,7 +83,7 @@  int select_watchdog_action(const char *p)
     action = qapi_enum_parse(&WatchdogAction_lookup, p, -1, NULL);
     if (action < 0)
         return -1;
-    watchdog_action = action;
+    qmp_watchdog_set_action(action, &error_abort);
     return 0;
 }
 
@@ -139,3 +140,8 @@  void watchdog_perform_action(void)
         assert(0);
     }
 }
+
+void qmp_watchdog_set_action(WatchdogAction action, Error **errp)
+{
+    watchdog_action = action;
+}
diff --git a/qapi-schema.json b/qapi-schema.json
index f3af2cb851..f5db401838 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3143,3 +3143,12 @@ 
 # Since 2.9
 ##
 { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
+
+##
+# @watchdog-set-action:
+#
+# Set watchdog action
+#
+# Since 2.11
+##
+{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} }