From: "Erik Schilling" <erik.schilling@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>,
openembedded-core@lists.openembedded.org
Cc: <richard.purdie@linuxfoundation.org>,
<alexandre.belloni@bootlin.com>,
"Mikko Rapeli" <mikko.rapeli@linaro.org>
Subject: Re: [RFC PATCH] qemurunner.py: ensure we drain stdout after boot prompt
Date: Wed, 29 Nov 2023 15:11:29 +0100 [thread overview]
Message-ID: <CXBCUNG34QJ6.2CKPAM8PWBE82@ablu-work> (raw)
In-Reply-To: <20231129124501.86503-1-alex.bennee@linaro.org>
On Wed Nov 29, 2023 at 1:45 PM CET, Alex Bennée wrote:
> If qemurunner doesn't continuously drain stdout we will eventually
> cause QEMU to block while trying to write to the pipe. This can
> manifest itself if the guest has for example configured its serial
> ports to output via stdio even if the test itself is using a TCP
> console or SSH to run things.
>
> This doesn't address a potential overflow of stderr although generally
> stderr from QEMU will be a lot less likely to block due to the volume
> of data.
>
> Suggested-by: Erik Schilling <erik.schilling@linaro.org>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: Mikko Rapeli <mikko.rapeli@linaro.org>
>
> ---
> AJB:
> As a QEMU developer I should note that we've had to solve a lot of
> similar problems within our own internal testing (e.g.
> https://gitlab.com/qemu-project/qemu/-/blob/master/python/qemu/machine/console_socket.py?ref_type=heads).
> Perhaps in the longer term it might make sense to consider using
> QEMU's own python tooling for configuring and launching QEMU?
> ---
> meta/lib/oeqa/utils/qemurunner.py | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
> index 29fe271976..1ec472c49e 100644
> --- a/meta/lib/oeqa/utils/qemurunner.py
> +++ b/meta/lib/oeqa/utils/qemurunner.py
> @@ -243,6 +243,7 @@ class QemuRunner:
> # to be a proper fix but this will suffice for now.
> self.runqemu = subprocess.Popen(launch_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, preexec_fn=os.setpgrp, env=env, cwd=self.tmpdir)
> output = self.runqemu.stdout
> + output_drain = output
> launch_time = time.time()
>
> #
> @@ -539,6 +540,17 @@ class QemuRunner:
> self.logger.warning("The output:\n%s" % output)
> except:
> self.logger.warning("Serial console failed while trying to login")
> +
> + def drain_log():
> + while not output_drain.closed:
> + more_output = self.getOutput(output_drain)
> + if len(more_output) > 0:
> + self.logger.debug("Logs since boot: %s", more_output)
> + time.sleep(0.1)
> +
> + t = threading.Thread(target=drain_log)
> + t.start()
> +
> return True
>
> def stop(self):
This is of course just a hack to demonstrate this was the problem. A
better solution would probably be to collect the logs through the
existing supervision process that gets forked off... That then also
solves the problem for the earlier code (and would transition nicely to
also drain stderr).
- Erik
next prev parent reply other threads:[~2023-11-29 14:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 12:45 [RFC PATCH] qemurunner.py: ensure we drain stdout after boot prompt Alex Bennée
2023-11-29 14:11 ` Erik Schilling [this message]
2023-11-29 14:56 ` Richard Purdie
2023-11-29 15:56 ` Alex Bennée
2023-11-29 15:59 ` Richard Purdie
2023-11-30 11:07 ` Alex Bennée
2023-11-30 11:16 ` Richard Purdie
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=CXBCUNG34QJ6.2CKPAM8PWBE82@ablu-work \
--to=erik.schilling@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=alexandre.belloni@bootlin.com \
--cc=mikko.rapeli@linaro.org \
--cc=openembedded-core@lists.openembedded.org \
--cc=richard.purdie@linuxfoundation.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