Skip to contentSkip to conversation

qmp: return err msg when powerdown a vm when it isn't in running state

PATCH Superseded Qinghua Jin 2 participants 3 messages Dec 22, 2015

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qmp: return err msg when powerdown a vm when it isn't in running state

This is an update of patch previously show in msg:

http://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03817.html

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qmp.c +6 -1
index 0a1fa19..384df56 100644
@@ -114,8 +114,13 @@ void qmp_system_reset(Error **errp)
     qemu_system_reset_request();
 }
 
-void qmp_system_powerdown(Error **erp)
+void qmp_system_powerdown(Error **errp)
 {
+    if (!runstate_check(RUN_STATE_RUNNING)) {
+        error_setg(errp,
+                   "Can not powerdown virtual machine as it is not running");
+        return;
+    }
     qemu_system_powerdown_request();
 }
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 3 lines · Qinghua Jin

This is an update of patch previously show in msg:

http://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03817.html

The patch looks good to me, thanks for submitting the patch! There is only one minor comment:

Patch revision note should go after the --- line (or the cover letter if you have one) so that it won't be commited into the git log (because it wouldn't be informative):

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.

---

This is an update of patch previously show in msg:

http://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03817.html

qmp.c | 7 ++++++-

Quoted 33 lines

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qmp.c +6 -1
index 0a1fa19..384df56 100644
@@ -114,8 +114,13 @@ void qmp_system_reset(Error **errp)
     qemu_system_reset_request();
 }
 
-void qmp_system_powerdown(Error **erp)
+void qmp_system_powerdown(Error **errp)
 {
+    if (!runstate_check(RUN_STATE_RUNNING)) {
+        error_setg(errp,
+                   "Can not powerdown virtual machine as it is not running");
+        return;
+    }
     qemu_system_powerdown_request();
 }
 
Signature · 1 line
2.5.0
#2 lore raw

Thanks for helping me, i'll use the patch format suggested by you.

Quoted 57 lines · Fam Zheng
Quoted 3 lines · Qinghua Jin

This is an update of patch previously show in msg:

http://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03817.html

The patch looks good to me, thanks for submitting the patch! There is only one minor comment:

Patch revision note should go after the --- line (or the cover letter if you have one) so that it won't be commited into the git log (because it wouldn't be informative):

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.

   Signed-off-by: Qinghua Jin <[email protected]>
   ---

   This is an update of patch previously show in msg:

     http://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03817.html

    qmp.c | 7 ++++++-
Quoted 33 lines

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qmp.c +6 -1
index 0a1fa19..384df56 100644
@@ -114,8 +114,13 @@ void qmp_system_reset(Error **errp)
     qemu_system_reset_request();
 }
 
-void qmp_system_powerdown(Error **erp)
+void qmp_system_powerdown(Error **errp)
 {
+    if (!runstate_check(RUN_STATE_RUNNING)) {
+        error_setg(errp,
+                   "Can not powerdown virtual machine as it is not running");
+        return;
+    }
     qemu_system_powerdown_request();
 }
 
Signature · 1 line
2.5.0