From: Aaron Sierra <asierra@xes-inc.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: Riku Voipio <riku.voipio@iki.fi>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] linux-user: Support explicit targets for PowerPC
Date: Tue, 7 Nov 2017 09:20:32 -0600 (CST) [thread overview]
Message-ID: <1997067362.187762.1510068032954.JavaMail.zimbra@xes-inc.com> (raw)
In-Reply-To: <c97adeea-32ee-269c-2a88-b011e8a294fa@vivier.eu>
----- Original Message -----
> From: "Laurent Vivier" <laurent@vivier.eu>
> Sent: Tuesday, November 7, 2017 3:24:52 AM
> Le 07/11/2017 à 03:50, Aaron Sierra a écrit :
>> Enable building PowerPC targets supporting a specific CPU, without
>> having to set QEMU_CPU via the environment. For example these build
>> targets (and many more) become available:
>>
>> qemu-ppc.e500mc qemu-ppc.e500v2 qemu-ppc.e5500 qemu-ppc.e600
>> qemu-ppc.e6500
>>
>> These (statically compiled) binaries have proven useful for
>> emulating PowerPC CPUs within Docker containers, where it's hard to
>> reliably define environment variables that are available for every
>> process.
>>
>
> An other idea would be to extract the default cpu from argv[0].
>
> We don't change the default CPU at compile time, but we check the binary
> name:
> - if it's qemu-ppc, let's use the default cpu for qemu-ppc
> - if it's not qemu-ppc, but something like qemu-ppc.XXX, let's set the
> CPU to XXX. For instance "qemu-ppc.e600" will be a shortcut for
> "qemu-ppc -cpu e600". [1]
>
> I think it's easy to implement and don't change the default behavior of
> qemu. And you can use hardlink to define several binaries with different
> defaults (like busybox)
Laurent,
I had that thought, too, as being the cleanest and simplest to implement,
but it didn't work out as a practical solution. Having execution depend
on the name of the file would require a lot of tuning of magics, masks,
and interpreters in /proc/sys/fs/binfmt_misc to get the behavior that I
depend on. It would require one entry per binary.
With the implementation that I've proposed, I only need two fairly generic
entries (ppc and ppc64) stock from Ubuntu's qemu-user-static package.
With Docker it's trivial to bind <any_path>/qemu-ppc.e500mc to
/usr/bin/qemu-ppc-static within the container. Which gives me complete
control over how the container is emulated.
-Aaron S.
>
> Thanks,
> Laurent
>
> [1] something like:
>
> -- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -4165,6 +4165,7 @@ static void usage(int exitcode)
> static int parse_args(int argc, char **argv)
> {
> const char *r;
> + const char *cpuname;
> int optind;
> const struct qemu_argument *arginfo;
>
> @@ -4179,6 +4180,11 @@ static int parse_args(int argc, char **argv)
> }
> }
>
> + cpuname = strrchr(argv[0], '.');
> + if (cpuname && cpuname[1] != 0) {
> + cpu_model = strdup(cpuname + 1);
> + }
> +
> optind = 1;
> for (;;) {
> if (optind >= argc) {
next prev parent reply other threads:[~2017-11-07 15:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 2:50 [Qemu-devel] [PATCH] linux-user: Support explicit targets for PowerPC Aaron Sierra
2017-11-07 4:48 ` no-reply
2017-11-07 4:51 ` no-reply
2017-11-07 6:57 ` Laurent Vivier
2017-11-07 9:29 ` Peter Maydell
2017-11-07 9:41 ` Laurent Vivier
2017-11-07 15:25 ` Aaron Sierra
2017-11-07 9:24 ` Laurent Vivier
2017-11-07 15:20 ` Aaron Sierra [this message]
2017-11-07 15:24 ` Peter Maydell
2017-11-07 15:28 ` Aaron Sierra
2017-11-07 15:27 ` Laurent Vivier
2017-11-07 15:42 ` Aaron Sierra
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=1997067362.187762.1510068032954.JavaMail.zimbra@xes-inc.com \
--to=asierra@xes-inc.com \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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).