qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, "Andreas Färber" <afaerber@suse.de>,
	"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH] qtest: Unlink pid file before reading from QMP
Date: Sun,  9 Feb 2014 12:21:41 +0100	[thread overview]
Message-ID: <1391944901-23475-1-git-send-email-afaerber@suse.de> (raw)

Despite 1ad3c6abc0d67e00b84abaa5527bc64b70ca2205, supplying invalid
arguments to the QEMU process still leaked a /tmp/qtest-*.pid file.

Fix this by reordering the reading and unlinking to before reading from
QMP socket, which relies on a running process.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 tests/libqtest.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index c9a4f89..9433782 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -157,14 +157,14 @@ QTestState *qtest_init(const char *extra_args)
         s->irq_level[i] = false;
     }
 
-    /* Read the QMP greeting and then do the handshake */
-    qtest_qmp_discard_response(s, "");
-    qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
-
     s->qemu_pid = read_pid_file(pid_file);
     unlink(pid_file);
     g_free(pid_file);
 
+    /* Read the QMP greeting and then do the handshake */
+    qtest_qmp_discard_response(s, "");
+    qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
+
     if (getenv("QTEST_STOP")) {
         kill(s->qemu_pid, SIGSTOP);
     }
-- 
1.8.4.5

             reply	other threads:[~2014-02-09 11:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-09 11:21 Andreas Färber [this message]
2014-02-14 14:43 ` [Qemu-devel] [PATCH] qtest: Unlink pid file before reading from QMP Stefan Hajnoczi
2014-02-14 15:38   ` Andreas Färber
2014-02-17 13:39     ` Stefan Hajnoczi

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=1391944901-23475-1-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).