From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com,
peter.maydell@linaro.org
Subject: Re: [PATCH] tests/qtest: Poll on waitpid() for a while before sending SIGKILL
Date: Thu, 12 Jan 2023 08:53:14 +0000 [thread overview]
Message-ID: <Y7/KeuE1itaHzA3i@redhat.com> (raw)
In-Reply-To: <20230111223018.3965423-1-stefanb@linux.ibm.com>
On Wed, Jan 11, 2023 at 05:30:18PM -0500, Stefan Berger wrote:
> To prevent getting stuck on waitpid() in case the target process does
> not terminate on SIGTERM, poll on waitpid() for 10s and if the target
> process has not changed state until then send a SIGKILL to it.
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> tests/qtest/libqtest.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
Since this is a test suite and we know our CI system gets very
heavily loaded, I think we should wait more than 10 secs, to
ensure QEMU has time to flush pending I/O in particular which
is most likely to delay things. If you bump the time to 30 secs
then
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index 2fbc3b88f3..362b1f724f 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -202,8 +202,24 @@ void qtest_wait_qemu(QTestState *s)
> {
> #ifndef _WIN32
> pid_t pid;
> + uint64_t end;
> +
> + /* poll for 10s until sending SIGKILL */
> + end = g_get_monotonic_time() + 10 * G_TIME_SPAN_SECOND;
> +
> + do {
> + pid = waitpid(s->qemu_pid, &s->wstatus, WNOHANG);
> + if (pid != 0) {
> + break;
> + }
> + g_usleep(100 * 1000);
> + } while (g_get_monotonic_time() < end);
> +
> + if (pid == 0) {
> + kill(s->qemu_pid, SIGKILL);
> + TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0));
> + }
>
> - TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0));
> assert(pid == s->qemu_pid);
> #else
> DWORD ret;
> --
> 2.39.0
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2023-01-12 9:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 22:30 [PATCH] tests/qtest: Poll on waitpid() for a while before sending SIGKILL Stefan Berger
2023-01-12 8:53 ` Daniel P. Berrangé [this message]
2023-01-12 9:18 ` Philippe Mathieu-Daudé
2023-01-12 9:54 ` Daniel P. Berrangé
2023-01-12 10:28 ` Philippe Mathieu-Daudé
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=Y7/KeuE1itaHzA3i@redhat.com \
--to=berrange@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.