From: Thomas Huth <thuth@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Eric Blake" <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 2/3] libqtest: fail if child coredumps
Date: Fri, 25 May 2018 08:10:48 +0200 [thread overview]
Message-ID: <ac1f972f-2769-9945-868d-e80a01842f4f@redhat.com> (raw)
In-Reply-To: <1527186303-192100-3-git-send-email-mst@redhat.com>
On 24.05.2018 20:25, Michael S. Tsirkin wrote:
> Right now tests report OK status if QEMU crashes during cleanup.
> Let's catch that case and fail the test.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> tests/libqtest.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 43fb97e..f869854 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -103,8 +103,15 @@ static int socket_accept(int sock)
> static void kill_qemu(QTestState *s)
> {
> if (s->qemu_pid != -1) {
> + int wstatus = 0;
> + pid_t pid;
> +
> kill(s->qemu_pid, SIGTERM);
> - waitpid(s->qemu_pid, NULL, 0);
> + pid = waitpid(s->qemu_pid, &wstatus, 0);
> +
> + if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
> + assert(!WCOREDUMP(wstatus));
Another ugliness that I just discovered: kill_qemu is also called from
the SIGABRT handler. So if a qtest assert() triggers an abort(), the
abort handler runs kill_qemu which now could trigger another assert()
and thus abort(). It's likely not a real problem since the abort handler
has been installed with SA_RESETHAND, but it's still quite confusing code.
Please let's clean up this ugliness properly: I think kill_qemu should
*only* be used by the abort handler, and then kill QEMU with SIGKILL for
good, to make sure that there are no stuck QEMU processes hanging around
anymore.
qtest_quit() should simply try to quit QEMU via QMP instead, and then
check for WIFEXITED(wstatus) && !WEXITSTATUS(wstatus) instead of using
the kill_qemu() function.
Thomas
next prev parent reply other threads:[~2018-05-25 6:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 18:25 [Qemu-devel] [PATCH v4 0/3] libqtest: verify QEMU exit status Michael S. Tsirkin
2018-05-24 18:25 ` [Qemu-devel] [PATCH v4 1/3] osdep: add wait.h compat macros Michael S. Tsirkin
2018-06-14 12:56 ` Markus Armbruster
2018-06-14 13:02 ` Peter Maydell
2018-05-24 18:25 ` [Qemu-devel] [PATCH v4 2/3] libqtest: fail if child coredumps Michael S. Tsirkin
2018-05-25 6:10 ` Thomas Huth [this message]
2018-05-25 11:22 ` Thomas Huth
2018-05-25 12:15 ` Michael S. Tsirkin
2018-05-25 14:05 ` Thomas Huth
2018-05-24 18:25 ` [Qemu-devel] [PATCH v4 3/3] libqtest: add more exit status checks Michael S. Tsirkin
2018-05-25 14:07 ` Michael S. Tsirkin
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=ac1f972f-2769-9945-868d-e80a01842f4f@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--cc=mst@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).