qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] qmp: return err msg when powerdown a vm when it isn't in running state
@ 2015-12-22  3:09 Qinghua Jin
  2015-12-22  6:54 ` P J P
  2016-01-18 13:50 ` Markus Armbruster
  0 siblings, 2 replies; 3+ messages in thread
From: Qinghua Jin @ 2015-12-22  3:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Qinghua Jin, Fam Zheng, Markus Armbruster, P J P

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 <qhjin_dev@163.com>
---

This is an update of the patch as per Fam Zheng's suggestion:
  http://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03949.html

 qmp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qmp.c b/qmp.c
index 0a1fa19..384df56 100644
--- a/qmp.c
+++ b/qmp.c
@@ -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();
 }
 
-- 
2.5.0

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

* Re: [Qemu-devel] [PATCH v3] qmp: return err msg when powerdown a vm when it isn't in running state
  2015-12-22  3:09 [Qemu-devel] [PATCH v3] qmp: return err msg when powerdown a vm when it isn't in running state Qinghua Jin
@ 2015-12-22  6:54 ` P J P
  2016-01-18 13:50 ` Markus Armbruster
  1 sibling, 0 replies; 3+ messages in thread
From: P J P @ 2015-12-22  6:54 UTC (permalink / raw)
  To: Qinghua Jin; +Cc: Fam Zheng, qemu-devel, Markus Armbruster

+-- On Tue, 22 Dec 2015, Qinghua Jin wrote --+
| -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();
|  }

Looks okay.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F

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

* Re: [Qemu-devel] [PATCH v3] qmp: return err msg when powerdown a vm when it isn't in running state
  2015-12-22  3:09 [Qemu-devel] [PATCH v3] qmp: return err msg when powerdown a vm when it isn't in running state Qinghua Jin
  2015-12-22  6:54 ` P J P
@ 2016-01-18 13:50 ` Markus Armbruster
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2016-01-18 13:50 UTC (permalink / raw)
  To: Qinghua Jin; +Cc: Fam Zheng, qemu-devel, P J P

Qinghua Jin <qhjin_dev@163.com> writes:

> 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 <qhjin_dev@163.com>
> ---
>
> This is an update of the patch as per Fam Zheng's suggestion:
>   http://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03949.html
>
>  qmp.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/qmp.c b/qmp.c
> index 0a1fa19..384df56 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -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();
>  }

This is the handler for QMP command system_powerdown.  The patch makes
the QMP command fail in run states other than RUN_STATE_RUNNING.

There are other callers: the HMP command handler hmp_system_powerdown(),
GTK's gd_menu_powerdown(), Cocoa's powerDownQEMU().  They all ignore the
error.  Why is that appropriate?

qemu_system_powerdown_request() sets powerdown_requested = 1.  This
makes the next qemu_powerdown_requested() return 1.  Gets called only by
main_loop_should_exit().  I can't quite see how "it will be ignored by
system" when we're in RUN_STATE_RUNNING.  Can you explain?

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

end of thread, other threads:[~2016-01-18 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-22  3:09 [Qemu-devel] [PATCH v3] qmp: return err msg when powerdown a vm when it isn't in running state Qinghua Jin
2015-12-22  6:54 ` P J P
2016-01-18 13:50 ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).