qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Andreas Faerber <afaerber@suse.de>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] qtest: make QEMU our direct child process
Date: Tue, 18 Feb 2014 10:00:36 +0100	[thread overview]
Message-ID: <20140218090036.GA32585@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <87bny5u1rs.fsf@blackfin.pond.sub.org>

On Mon, Feb 17, 2014 at 05:44:55PM +0100, Markus Armbruster wrote:
> Stefan Hajnoczi <stefanha@redhat.com> writes:
> 
> > qtest_init() cannot use exec*p() to launch QEMU since the exec*p()
> > functions take an argument array while qtest_init() takes char
> > *extra_args.  Therefore we execute /bin/sh -c <command-line> and let the
> > shell parse the argument string.
> >
> > This left /bin/sh as our child process and our child's child was QEMU.
> > We still want QEMU's pid so the -pidfile option was used to let QEMU
> > report its pid.
> >
> > The pidfile needs to be unlinked when the test case exits or fails.  In
> > other words, the pidfile creates a new problem for us!
> >
> > Simplify all this using the shell 'exec' command.  It allows us to
> > replace the /bin/sh process with QEMU.  Then we no longer need to use
> > -pidfile because we already know our fork child's pid.
> >
> > Note: Yes, it seems silly to exec /bin/sh when we could just exec QEMU
> > directly.  But remember qtest_init() takes a single char *extra_args
> > command-line fragment instead of a real argv[] array, so we need
> > /bin/sh's argument parsing behavior.
> 
> Sounds like a design mistake to me.

I wouldn't call char *extra_args a mistake because strings are still
simpler to manipulate in C than char *argv[] arrays.  So we write less
code in test cases and libqtest.c at the expense of a roundabout way to
spawn the process.

Stefan

  reply	other threads:[~2014-02-18  9:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 15:44 [Qemu-devel] [PATCH 0/3] qtest: avoid pidfile and QEMU process leaks Stefan Hajnoczi
2014-02-17 15:44 ` [Qemu-devel] [PATCH 1/3] qtest: drop unused child_pid field Stefan Hajnoczi
2014-02-17 15:44 ` [Qemu-devel] [PATCH 2/3] qtest: make QEMU our direct child process Stefan Hajnoczi
2014-02-17 16:44   ` Markus Armbruster
2014-02-18  9:00     ` Stefan Hajnoczi [this message]
2014-02-18  9:53       ` Markus Armbruster
2014-02-17 15:44 ` [Qemu-devel] [PATCH 3/3] qtest: kill QEMU process on g_assert() failure Stefan Hajnoczi
2014-02-17 16:16   ` Paolo Bonzini
2014-02-17 17:00     ` Markus Armbruster
2014-02-18  9:05       ` Stefan Hajnoczi
2014-02-18 10:05         ` Markus Armbruster
2014-02-18 10:23           ` Paolo Bonzini
2014-02-18 10:43             ` Markus Armbruster
2014-02-18 14:38               ` Stefan Hajnoczi
2014-02-18 10:07         ` Paolo Bonzini
2014-02-18 10:17           ` Daniel P. Berrange
2014-02-18 10:23             ` Paolo Bonzini
2014-02-17 16:49   ` Markus Armbruster
2014-02-17 16:56     ` Paolo Bonzini
2014-02-18  9:17     ` Stefan Hajnoczi
2014-02-18  9:55       ` Markus Armbruster
2014-02-18 14:44         ` Stefan Hajnoczi
2014-02-18 14:56       ` Peter Maydell
2014-02-18 10:02     ` Markus Armbruster
2014-02-18 14:38       ` Stefan Hajnoczi
2014-02-18 14:52         ` Markus Armbruster

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=20140218090036.GA32585@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --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).