qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH 3/3] Monitor: Return before exiting with 'quit'
Date: Wed, 12 May 2010 14:52:48 -0300	[thread overview]
Message-ID: <1273686768-26561-4-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1273686768-26561-1-git-send-email-lcapitulino@redhat.com>

This is a new version of the (now reverted) following commit:

0e8d2b5575938b8876a3c4bb66ee13c5d306fb6d

The 'quit' Monitor command (implemented by do_quit()) calls
exit() directly, this is problematic under QMP because QEMU
exits before having a chance to send the ok response.

Clients don't know if QEMU exited because of a problem or
because the 'quit' command has been executed.

This commit fixes that by making do_quit() use
qemu_system_shutdown_request(), so that we exit gracefully.

Thanks to Paolo Bonzini <pbonzini@redhat.com> for suggesting
this solution.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/monitor.c b/monitor.c
index e984122..15b53b9 100644
--- a/monitor.c
+++ b/monitor.c
@@ -942,7 +942,10 @@ static void do_info_cpu_stats(Monitor *mon)
  */
 static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
-    exit(0);
+    monitor_suspend(mon);
+    no_shutdown = 0;
+    qemu_system_shutdown_request();
+
     return 0;
 }
 
-- 
1.7.1.11.g3bf78

  parent reply	other threads:[~2010-05-12 17:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-12 17:52 [Qemu-devel] [PATCH 0/3]: Monitor: Better fix for 'quit' return Luiz Capitulino
2010-05-12 17:52 ` [Qemu-devel] [PATCH 1/3] Revert "Monitor: Return before exiting with 'quit'" Luiz Capitulino
2010-05-12 17:52 ` [Qemu-devel] [PATCH 2/3] sysemu: Export 'no_shutdown' Luiz Capitulino
2010-05-12 17:52 ` Luiz Capitulino [this message]
2010-05-13  7:18 ` [Qemu-devel] Re: [PATCH 0/3]: Monitor: Better fix for 'quit' return Paolo Bonzini
2010-05-13 13:30 ` [Qemu-devel] " Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1273686768-26561-4-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).