[PATCH 3/4] qmp: Allow setting -action parameters on the fly

Alejandro Jimenez posted 4 patches 5 years, 2 months ago
Maintainers: Eric Blake <eblake@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Markus Armbruster <armbru@redhat.com>, Thomas Huth <thuth@redhat.com>
There is a newer version of this series
[PATCH 3/4] qmp: Allow setting -action parameters on the fly
Posted by Alejandro Jimenez 5 years, 2 months ago
Add QMP commands to allow for the behaviors specified by the
-action event=action command line option to be set at runtime,
mimicking the watchdog-set-action QMP command.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
---
 qapi/run-state.json       | 27 +++++++++++++++++++++++++++
 softmmu/runstate-action.c |  6 +++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/qapi/run-state.json b/qapi/run-state.json
index 27b62ce..de27516 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -451,6 +451,33 @@
 { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} }
 
 ##
+# @reboot-set-action:
+#
+# Set reboot action
+#
+# Since: 6.0
+##
+{ 'command': 'reboot-set-action', 'data' : {'action': 'RebootAction'} }
+
+##
+# @shutdown-set-action:
+#
+# Set shutdown action
+#
+# Since: 6.0
+##
+{ 'command': 'shutdown-set-action', 'data' : {'action': 'ShutdownAction'} }
+
+##
+# @panic-set-action:
+#
+# Set panic action
+#
+# Since: 6.0
+##
+{ 'command': 'panic-set-action', 'data' : {'action': 'PanicAction'} }
+
+##
 # @GUEST_PANICKED:
 #
 # Emitted when guest OS panic is detected
diff --git a/softmmu/runstate-action.c b/softmmu/runstate-action.c
index 9c92595..aef23b8 100644
--- a/softmmu/runstate-action.c
+++ b/softmmu/runstate-action.c
@@ -29,7 +29,7 @@ static void runstate_action_help(void)
  * Set the internal state to react to a guest reboot event
  * as specified by the action parameter.
  */
-static void qmp_reboot_set_action(RebootAction act, Error **errp)
+void qmp_reboot_set_action(RebootAction act, Error **errp)
 {
     switch (act) {
     case REBOOT_ACTION_NONE:
@@ -47,7 +47,7 @@ static void qmp_reboot_set_action(RebootAction act, Error **errp)
  * Set the internal state to react to a guest shutdown event
  * as specified by the action parameter.
  */
-static void qmp_shutdown_set_action(ShutdownAction act, Error **errp)
+void qmp_shutdown_set_action(ShutdownAction act, Error **errp)
 {
     switch (act) {
     case SHUTDOWN_ACTION_PAUSE:
@@ -65,7 +65,7 @@ static void qmp_shutdown_set_action(ShutdownAction act, Error **errp)
  * Set the internal state to react to a guest panic event
  * as specified by the action parameter.
  */
-static void qmp_panic_set_action(PanicAction action, Error **errp)
+void qmp_panic_set_action(PanicAction action, Error **errp)
 {
     switch (action) {
     case PANIC_ACTION_NONE:
-- 
1.8.3.1


Re: [PATCH 3/4] qmp: Allow setting -action parameters on the fly
Posted by Paolo Bonzini 5 years, 2 months ago
On 08/12/20 20:14, Alejandro Jimenez wrote:
>   ##
> +# @reboot-set-action:
> +#
> +# Set reboot action
> +#
> +# Since: 6.0
> +##
> +{ 'command': 'reboot-set-action', 'data' : {'action': 'RebootAction'} }
> +
> +##
> +# @shutdown-set-action:
> +#
> +# Set shutdown action
> +#
> +# Since: 6.0
> +##
> +{ 'command': 'shutdown-set-action', 'data' : {'action': 'ShutdownAction'} }
> +
> +##
> +# @panic-set-action:
> +#
> +# Set panic action
> +#
> +# Since: 6.0
> +##
> +{ 'command': 'panic-set-action', 'data' : {'action': 'PanicAction'} }
> +
> +##

What about a single action-set command with arguments reboot, shutdown 
and panic?

Paolo


Re: [PATCH 3/4] qmp: Allow setting -action parameters on the fly
Posted by Paolo Bonzini 5 years, 2 months ago
On 08/12/20 20:57, Paolo Bonzini wrote:
> On 08/12/20 20:14, Alejandro Jimenez wrote:
>>   ##
>> +# @reboot-set-action:
>> +#
>> +# Set reboot action
>> +#
>> +# Since: 6.0
>> +##
>> +{ 'command': 'reboot-set-action', 'data' : {'action': 'RebootAction'} }
>> +
>> +##
>> +# @shutdown-set-action:
>> +#
>> +# Set shutdown action
>> +#
>> +# Since: 6.0
>> +##
>> +{ 'command': 'shutdown-set-action', 'data' : {'action': 
>> 'ShutdownAction'} }
>> +
>> +##
>> +# @panic-set-action:
>> +#
>> +# Set panic action
>> +#
>> +# Since: 6.0
>> +##
>> +{ 'command': 'panic-set-action', 'data' : {'action': 'PanicAction'} }
>> +
>> +##
> 
> What about a single action-set command with arguments reboot, shutdown 
> and panic?

(and watchdog, of course)?

Paolo

Re: [PATCH 3/4] qmp: Allow setting -action parameters on the fly
Posted by Alejandro Jimenez 5 years, 2 months ago

On 12/8/2020 2:58 PM, Paolo Bonzini wrote:
> On 08/12/20 20:57, Paolo Bonzini wrote:
>> On 08/12/20 20:14, Alejandro Jimenez wrote:
>>>   ##
>>> +# @reboot-set-action:
>>> +#
>>> +# Set reboot action
>>> +#
>>> +# Since: 6.0
>>> +##
>>> +{ 'command': 'reboot-set-action', 'data' : {'action': 
>>> 'RebootAction'} }
>>> +
>>> +##
>>> +# @shutdown-set-action:
>>> +#
>>> +# Set shutdown action
>>> +#
>>> +# Since: 6.0
>>> +##
>>> +{ 'command': 'shutdown-set-action', 'data' : {'action': 
>>> 'ShutdownAction'} }
>>> +
>>> +##
>>> +# @panic-set-action:
>>> +#
>>> +# Set panic action
>>> +#
>>> +# Since: 6.0
>>> +##
>>> +{ 'command': 'panic-set-action', 'data' : {'action': 'PanicAction'} }
>>> +
>>> +##
>>
>> What about a single action-set command with arguments reboot, 
>> shutdown and panic?
>
> (and watchdog, of course)?
Just to make sure I understand the request: an action-set QMP command 
would need to take two arguments: an event 
(reboot|shutdown|panic|watchdog), and a valid action for that event 
type, akin to what set_runstate_action() does. I'll work on it.

Alejandro
>
> Paolo