All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] tests/qtest: Make qtest_get_arch() cleverer
Date: Mon, 27 Apr 2026 12:40:41 -0300	[thread overview]
Message-ID: <87h5owif7q.fsf@suse.de> (raw)
In-Reply-To: <20260427150007.1185559-1-peter.maydell@linaro.org>

Peter Maydell <peter.maydell@linaro.org> writes:

> The qtest_get_arch() function tries to determine the architecture
> under test by extracting it from the binary name as provided in
> QTEST_QEMU_BINARY.  The current logic finds the last '-' in the
> string and assumes everything beyond it is the architecture name.
> Although we also look for the substring "-system-", the only effect
> this check has is that we will exit with an error if it is not
> present.
>
> Because the logic at the moment is very simplistic, although
> it is possible to provide more complex commands than a bare
> QEMU binary path, such as:
>   QTEST_QEMU_BINARY='rr record ./qemu-system-x86_64'
> it is not possible to provide extra arguments to QEMU, such as:
>   QTEST_QEMU_BINARY='./qemu-system-x86_64 -d trace:foo'
>
> Because the "-system-" check and the "find the architecture" check
> are not the same, the latter example will pass the "we found
> -system-" check and not notice that the "architecture name" it has
> found starts further on in the string; so rather than printing an
> error it will return "d trace:foo" to the test.
>
> Improve the "find the architecture name" logic to look for the
> rightmost occurrence of the substring "-system-" in
> QTEST_QEMU_BINARY, and take the architecture name as starting there
> and continuing until the first whitespace character or the end of the
> string.
>
> Because we now need to potentially modify the environment variable
> string to terminate the architecture name if it is not the last part
> of the string, we make a copy of it which we cache in a static
> variable.  This lets us avoid having to modify all the callers to get
> them to take ownership of the returned string.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> I wanted to be able to pass trace arguments to a QEMU to help
> debug a failing test; in the past I've done this by writing
> a little wrapper shell script with the right shaped name, but
> we can do better than that.
>

There's QTEST_TRACE which can inject any command line option if you give
it a tracepoint name as first string:

QTEST_TRACE="cpu_reset -d guest_errors"

Maybe we should just rename it to QTEST_QEMU_ARGS.



  reply	other threads:[~2026-04-27 15:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 15:00 [PATCH] tests/qtest: Make qtest_get_arch() cleverer Peter Maydell
2026-04-27 15:40 ` Fabiano Rosas [this message]
2026-04-27 16:13   ` Peter Maydell

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=87h5owif7q.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 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.