From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6ThP-00008C-N1 for qemu-devel@nongnu.org; Mon, 26 Apr 2010 15:10:31 -0400 Received: from [140.186.70.92] (port=38576 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6ThN-000068-U7 for qemu-devel@nongnu.org; Mon, 26 Apr 2010 15:10:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6ThL-0002qc-Pj for qemu-devel@nongnu.org; Mon, 26 Apr 2010 15:10:29 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:49658) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6ThL-0002pf-EN for qemu-devel@nongnu.org; Mon, 26 Apr 2010 15:10:27 -0400 Message-ID: <4BD5E51A.9070402@web.de> Date: Mon, 26 Apr 2010 21:10:18 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1272296853-30285-1-git-send-email-lcapitulino@redhat.com> <1272296853-30285-6-git-send-email-lcapitulino@redhat.com> <4BD5D234.2030508@codemonkey.ws> <20100426152238.5ece1c15@redhat.com> <4BD5DAA2.4050206@codemonkey.ws> <20100426155303.2c381ff7@redhat.com> <4BD5E2BB.8000105@codemonkey.ws> In-Reply-To: <4BD5E2BB.8000105@codemonkey.ws> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig94A74CAD1F4BB57A5670731D" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH 5/9] Monitor: Return before exiting with 'quit' List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig94A74CAD1F4BB57A5670731D Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Anthony Liguori wrote: > On 04/26/2010 01:53 PM, Luiz Capitulino wrote: >> On Mon, 26 Apr 2010 13:25:38 -0500 >> Anthony Liguori wrote: >> >> =20 >>> On 04/26/2010 01:22 PM, Luiz Capitulino wrote: >>> =20 >>>> On Mon, 26 Apr 2010 12:49:40 -0500 >>>> Anthony Liguori wrote: >>>> >>>> >>>> =20 >>>>> On 04/26/2010 10:47 AM, Luiz Capitulino wrote: >>>>> >>>>> =20 >>>>>> 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 moving the exit() call to the main >>>>>> loop, so that do_quit() requests the system to quit, instead >>>>>> of calling exit() directly. >>>>>> >>>>>> >>>>>> =20 >>>>> Does this also have the effect of printing out a (qemu) prompt afte= r >>>>> quit before an EOF appears on that socket? >>>>> >>>>> =20 >>>> Ah, right.. >>>> >>>> =20 >>> It's not necessarily a bad thing if it does. I just wanted to raise >>> that because it's possible that someone depends on the behavior. >>> =20 >> Yes, and it's also a bit ugly if you do '-monitor stdio': >> >> ~/stuff/virt/ ./qemu-qmp -monitor stdio >> QEMU 0.12.50 monitor - type 'help' for more information >> (qemu) quit >> (qemu) ~/stuff/virt/ >> >> So, I'd like to fix it. >> >> =20 >>> I'm not sure it matters to me if we change this behavior though. >>> =20 >> It's very easy to fix, the following patch does it. >> >> I have (tested and) rebased the for-anthony branch with it. >> >> From 14ecef47d1989f9b646fc0fe7a4bf42c091d1432 Mon Sep 17 00:00:00 200= 1 >> From: Luiz Capitulino >> Date: Tue, 6 Apr 2010 18:55:54 -0300 >> Subject: [PATCH 5/9] Monitor: Return before exiting with 'quit' >> >> 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 moving the exit() call to the main >> loop, so that do_quit() requests the system to quit, instead >> of calling exit() directly. >> >> Signed-off-by: Luiz Capitulino >> --- >> monitor.c | 7 ++++++- >> sysemu.h | 2 ++ >> vl.c | 18 ++++++++++++++++++ >> 3 files changed, 26 insertions(+), 1 deletions(-) >> >> diff --git a/monitor.c b/monitor.c >> index ef84298..5b0258f 100644 >> --- a/monitor.c >> +++ b/monitor.c >> @@ -1017,7 +1017,12 @@ static void do_info_cpu_stats(Monitor *mon) >> */ >> static int do_quit(Monitor *mon, const QDict *qdict, QObject >> **ret_data) >> { >> - exit(0); >> + if (monitor_ctrl_mode(mon)) { >> + qemu_system_exit_request(); >> + } else { >> + exit(0); >> + } >> + >> =20 >=20 > Now they have different behaviors though because > qemu_system_exit_request() actually exits gracefully. >=20 > For instance, now in QMP mode, an ifdown script will be executed when > the 'quit' command is invoked whereas it won't be executed when done > through the human monitor. >=20 > I honestly don't mind the weird print outs with -monitor stdio. I thin= k > exiting gracefully in both cases is better. Just suspend the monitor before leaving for termination. That should have both the proper visual and functional effect. Jan --------------enig94A74CAD1F4BB57A5670731D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkvV5R4ACgkQitSsb3rl5xTjHQCfT4T/x1k8JxZ7mudFeKwBpSiX iyQAni9spmzmo+8W5tGMip80ikKii5Dk =vC2O -----END PGP SIGNATURE----- --------------enig94A74CAD1F4BB57A5670731D--