All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] watchdog: Allow setting action on the fly
@ 2017-09-05 11:10 Michal Privoznik
  2017-09-05 11:50 ` Markus Armbruster
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Privoznik @ 2017-09-05 11:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: eblake, armbru

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 | 9 +++++++++
 qapi-schema.json       | 9 +++++++++
 2 files changed, 18 insertions(+)

diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 0c5c9cde1c..971f05c61a 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -29,6 +29,8 @@
 #include "qapi-event.h"
 #include "hw/nmi.h"
 #include "qemu/help_option.h"
+#include "qmp-commands.h"
+#include "qapi/qmp/qerror.h"
 
 static int watchdog_action = WDT_RESET;
 static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
@@ -147,3 +149,10 @@ void watchdog_perform_action(void)
         break;
     }
 }
+
+void qmp_watchdog_set_action(const char *action, Error **errp)
+{
+    if (select_watchdog_action(action) == -1) {
+        error_setg(errp, QERR_INVALID_PARAMETER, action);
+    }
+}
diff --git a/qapi-schema.json b/qapi-schema.json
index 802ea53d00..be81ffc0bb 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -6539,3 +6539,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': 'str'} }
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] watchdog: Allow setting action on the fly
  2017-09-05 11:10 [Qemu-devel] [PATCH] watchdog: Allow setting action on the fly Michal Privoznik
@ 2017-09-05 11:50 ` Markus Armbruster
  2017-09-05 11:54   ` Michal Privoznik
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2017-09-05 11:50 UTC (permalink / raw)
  To: Michal Privoznik; +Cc: qemu-devel

Michal Privoznik <mprivozn@redhat.com> writes:

> 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 | 9 +++++++++
>  qapi-schema.json       | 9 +++++++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
> index 0c5c9cde1c..971f05c61a 100644
> --- a/hw/watchdog/watchdog.c
> +++ b/hw/watchdog/watchdog.c
> @@ -29,6 +29,8 @@
>  #include "qapi-event.h"
>  #include "hw/nmi.h"
>  #include "qemu/help_option.h"
> +#include "qmp-commands.h"
> +#include "qapi/qmp/qerror.h"
>  
>  static int watchdog_action = WDT_RESET;
>  static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
> @@ -147,3 +149,10 @@ void watchdog_perform_action(void)
>          break;
>      }
>  }
> +
> +void qmp_watchdog_set_action(const char *action, Error **errp)
> +{
> +    if (select_watchdog_action(action) == -1) {
> +        error_setg(errp, QERR_INVALID_PARAMETER, action);
> +    }
> +}
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 802ea53d00..be81ffc0bb 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -6539,3 +6539,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': 'str'} }

@action needs to be a QAPI enum.  It'll replace the #defines in
watchdog.  select_watchdog_action() then calls qapi_enum_parse() to map
string to enum, and qmp_watchdog_set_action() to make the actual change.

Questions?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] watchdog: Allow setting action on the fly
  2017-09-05 11:50 ` Markus Armbruster
@ 2017-09-05 11:54   ` Michal Privoznik
  2017-09-05 12:01     ` Markus Armbruster
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Privoznik @ 2017-09-05 11:54 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel

On 09/05/2017 01:50 PM, Markus Armbruster wrote:
> Michal Privoznik <mprivozn@redhat.com> writes:
> 
>> 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 | 9 +++++++++
>>  qapi-schema.json       | 9 +++++++++
>>  2 files changed, 18 insertions(+)
>>
>> diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
>> index 0c5c9cde1c..971f05c61a 100644
>> --- a/hw/watchdog/watchdog.c
>> +++ b/hw/watchdog/watchdog.c
>> @@ -29,6 +29,8 @@
>>  #include "qapi-event.h"
>>  #include "hw/nmi.h"
>>  #include "qemu/help_option.h"
>> +#include "qmp-commands.h"
>> +#include "qapi/qmp/qerror.h"
>>  
>>  static int watchdog_action = WDT_RESET;
>>  static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list;
>> @@ -147,3 +149,10 @@ void watchdog_perform_action(void)
>>          break;
>>      }
>>  }
>> +
>> +void qmp_watchdog_set_action(const char *action, Error **errp)
>> +{
>> +    if (select_watchdog_action(action) == -1) {
>> +        error_setg(errp, QERR_INVALID_PARAMETER, action);
>> +    }
>> +}
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index 802ea53d00..be81ffc0bb 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -6539,3 +6539,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': 'str'} }
> 
> @action needs to be a QAPI enum.  It'll replace the #defines in
> watchdog.  select_watchdog_action() then calls qapi_enum_parse() to map
> string to enum, and qmp_watchdog_set_action() to make the actual change.

Oh, okay. Sure, I can do that. I guess it makes the set of actions
introspectable?

Michal

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] watchdog: Allow setting action on the fly
  2017-09-05 11:54   ` Michal Privoznik
@ 2017-09-05 12:01     ` Markus Armbruster
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2017-09-05 12:01 UTC (permalink / raw)
  To: Michal Privoznik; +Cc: qemu-devel

Michal Privoznik <mprivozn@redhat.com> writes:

> On 09/05/2017 01:50 PM, Markus Armbruster wrote:
>> 
>> @action needs to be a QAPI enum.  It'll replace the #defines in
>> watchdog.  select_watchdog_action() then calls qapi_enum_parse() to map
>> string to enum, and qmp_watchdog_set_action() to make the actual change.
>
> Oh, okay. Sure, I can do that. I guess it makes the set of actions
> introspectable?

Yes!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-05 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 11:10 [Qemu-devel] [PATCH] watchdog: Allow setting action on the fly Michal Privoznik
2017-09-05 11:50 ` Markus Armbruster
2017-09-05 11:54   ` Michal Privoznik
2017-09-05 12:01     ` Markus Armbruster

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.