Received: from eggs.gnu.org ([2001:4830:134:3::10]:51989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFRJb-0006Ul-9D for qemu-devel@nongnu.org; Mon, 17 Feb 2014 11:45:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFRJV-0005F6-Ay for qemu-devel@nongnu.org; Mon, 17 Feb 2014 11:45:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFRJV-0005Ev-2a for qemu-devel@nongnu.org; Mon, 17 Feb 2014 11:45:01 -0500 From: Markus Armbruster References: <1392651898-16749-1-git-send-email-stefanha@redhat.com> <1392651898-16749-3-git-send-email-stefanha@redhat.com> Date: Mon, 17 Feb 2014 17:44:55 +0100 In-Reply-To: <1392651898-16749-3-git-send-email-stefanha@redhat.com> (Stefan Hajnoczi's message of "Mon, 17 Feb 2014 16:44:57 +0100") Message-ID: <87bny5u1rs.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 2/3] qtest: make QEMU our direct child process List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Peter Maydell , qemu-devel@nongnu.org, Anthony Liguori , Andreas Faerber Stefan Hajnoczi 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 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. > Signed-off-by: Stefan Hajnoczi Patch looks good.