qmp: return err msg when powerdown a vm when it isn't in running state
PATCH 1/1 qmp: return err msg when powerdown a vm when it isn't in running state
When send system_powerdown to QMP when the vm isn't in RUN_STATE_RUNNING, it will be ignored by system. So reply a err msg with the situation.
--- qmp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
qmp.c +5 -1
@@ -114,8 +114,12 @@ void qmp_system_reset(Error **errp)qemu_system_reset_request (); } -void qmp_system_powerdown (Error **erp) +void qmp_system_powerdown (Error **errp) { +if (!runstate_is_running ()) { +error_setg (errp,"Can't powerdown the Virtual Machine when it isn't running" ); +return ; + }qemu_system_powerdown_request (); }
Signature · 1 line
2.5.0
+-- On Mon, 21 Dec 2015, Qinghua Jin wrote --+
| -void qmp_system_powerdown(Error **erp)
| +void qmp_system_powerdown(Error **errp)
| {
| + if (!runstate_is_running()) {
| + error_setg(errp, "Can't powerdown the Virtual Machine when it isn't running");
| + return;
| + }
| qemu_system_powerdown_request();
| } - Maybe direct call to 'if (!runstate_check(RUN_STATE_RUNNING))' is better? runstate_is_running too invokes the same. Not sure why are there two functions 'runstate_is_running' & 'runstate_check'.
- Can't -> Can not
- "...the Virtual Machine.." -> "...virtual machine.." (not capitalised)
- "...when it isn't.." -> "as it is not..."
- OR maybe just say -> "Virtual machine is not running"
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F
Thanks for your help, i'll resubmit the patch right away.
Quoted 22 lines · P J P
+-- On Mon, 21 Dec 2015, Qinghua Jin wrote --+ | -void qmp_system_powerdown(Error **erp) | +void qmp_system_powerdown(Error **errp) | { | + if (!runstate_is_running()) { | + error_setg(errp, "Can't powerdown the Virtual Machine when it isn't running"); | + return; | + } | qemu_system_powerdown_request(); | }- Maybe direct call to 'if (!runstate_check(RUN_STATE_RUNNING))' is better?
runstate_is_runningtoo invokes the same. Not sure why are there two functions 'runstate_is_running' & 'runstate_check'.
- Can't -> Can not
- "...the Virtual Machine.." -> "...virtual machine.." (not capitalised)
- "...when it isn't.." -> "as it is not..."
- OR maybe just say -> "Virtual machine is not running"--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F