Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-14 Thread Peter Maydell
On Mon, 14 Feb 2022 at 13:06, Liviu Ionescu  wrote:
>
>
>
> > On 14 Feb 2022, at 14:28, Daniel P. Berrangé  wrote:
> >
> > In a .git checkout, pkgversion defaults to "git describe --match 'v*' 
> > --dirty"
> > See scripts/qemu-version.sh
>
> I see. I would say that this is a different use case.

It's just a handy default for git checkouts. The primary use case
of pkgversion is exactly "this is a downstream packaging of QEMU
that wants to indicate that in the version string".

-- PMM



Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-14 Thread Liviu Ionescu



> On 14 Feb 2022, at 14:28, Daniel P. Berrangé  wrote:
> 
> In a .git checkout, pkgversion defaults to "git describe --match 'v*' --dirty"
> See scripts/qemu-version.sh

I see. I would say that this is a different use case.

Thank you,

Liviu




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-14 Thread Daniel P . Berrangé
On Mon, Feb 14, 2022 at 03:05:58PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 14 Feb 2022, at 14:28, Daniel P. Berrangé  wrote:
> > 
> > In a .git checkout, pkgversion defaults to "git describe --match 'v*' 
> > --dirty"
> > See scripts/qemu-version.sh
> 
> I see. I would say that this is a different use case.

That's only a default, you can set it to whatever value you want it to
be with the configure arg, if you don't like that info.

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 :|




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-14 Thread Daniel P . Berrangé
On Mon, Feb 14, 2022 at 02:18:13PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 14 Feb 2022, at 14:06, Peter Maydell  wrote:
> > 
> > ... but the "v6.2.0-1-xpack-arm" pkgversion suffix works for this
> > purpose too.
> 
> Currently I do not use any --pkgversion in my builds, so I guess that
> this is automatically generated by the meson script, and reflects the
> name of a custom branch in my fork; if I switch to using the upstream
> repo, this will probably be replace by some tag or commit id, which
> identifies the exact version, isn't it?

In a .git checkout, pkgversion defaults to "git describe --match 'v*' --dirty"
See scripts/qemu-version.sh

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 :|




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-14 Thread Liviu Ionescu



> On 14 Feb 2022, at 14:06, Peter Maydell  wrote:
> 
> ... but the "v6.2.0-1-xpack-arm" pkgversion suffix works for this
> purpose too.

Currently I do not use any --pkgversion in my builds, so I guess that this is 
automatically generated by the meson script, and reflects the name of a custom 
branch in my fork; if I switch to using the upstream repo, this will probably 
be replace by some tag or commit id, which identifies the exact version, isn't 
it?


Liviu




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-14 Thread Peter Maydell
On Mon, 14 Feb 2022 at 11:54, Liviu Ionescu  wrote:
> Would you agree on a multi step approach, first a minimal patch that would 
> solve my use case, then, if there will be others needing it, a more elaborate 
> solution?
>
> For example I don't mind having to pass a preprocessor definition to my 
> build; so how about something like:
>
>
> ```c
> static void version(void)
> {
> +#if defined(QEMU_BRANDING_PREFIX)
> +printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
> printf("QEMU emulator version " QEMU_FULL_VERSION "\n"
>QEMU_COPYRIGHT "\n");
> }
> ```

Either we want the feature upstream, or we don't. If we do, then
we want the whole thing including the configure option. If we don't,
then we don't want any of it, and that includes not having this kind
of ifdef.

So far you haven't really described a use case that --with-pkgversion
wouldn't satisfy. You say:

> Seeing the branded greeting in a console log is a visual confirmation
> that the test script used the desired version, and not another version
> picked up by mistake when using an incorrect PATH.

but the "v6.2.0-1-xpack-arm" pkgversion suffix works for this
purpose too.

thanks
-- PMM



Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-14 Thread Liviu Ionescu



> On 8 Feb 2022, at 21:58, Peter Maydell  wrote:
> 
> I've cc'd some people who might have an opinion on whether this
> something we want to add upstream. ...

Well, given the comments received, it is obvious that we have different use 
cases, and, in my opinion, a one-size-fits-all approach cannot be expected to 
satisfy all of them. :-(


Since QEMU is now a hard dependency in all my projects (for running unit 
tests), I had to commit myself on continuing to maintain the xPack QEMU binary 
distribution used by these tests.

Thus my desire to minimise maintenance during updates, for example by keeping 
as little things as possible in a local fork.


So, if the Linux maintainers do not find a compelling reason for adding 
`--with-branding-prefix` and are concerned that this might break their 
distributions (which it will not, since they will not use this option), what 
would be an acceptable solution to allow more flexibility in the main QEMU 
greeting message? Personally I use only qemu-system-arm and qemu-system-riscv, 
so we are talking only about a change in `vl.c`; I do not use the other tools, 
so not having them updated is not a concern.


Would you agree on a multi step approach, first a minimal patch that would 
solve my use case, then, if there will be others needing it, a more elaborate 
solution?

For example I don't mind having to pass a preprocessor definition to my build; 
so how about something like:


```c
static void version(void)
{
+#if defined(QEMU_BRANDING_PREFIX)
+printf("%s ", QEMU_BRANDING_PREFIX);
+#endif
printf("QEMU emulator version " QEMU_FULL_VERSION "\n"
   QEMU_COPYRIGHT "\n");
}
```


This would harm no existing distributions, and would add no maintenance efforts 
for none of you, but would save me some recurrent maintenance efforts with each 
release.


Would this be fine with you?



Regards,

Liviu






Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-09 Thread Daniel P . Berrangé
On Wed, Feb 09, 2022 at 12:13:02PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 9 Feb 2022, at 11:57, Stefan Hajnoczi  wrote:
> > 
> > 
> > Is the existing ./configure --with-pkgversion= option not enough?
> 
> My understanding of --with-pkgversion=, based on the fact that in QEMU this 
> string is appended to the version, was that it is a suffix that describes a 
> specific version.
> 
> Most GNU tools, including GCC, binutils, etc, use a similar option, but the 
> string is prepended to the greeting message.
> 
> In my use case, --with-branding-prefix does the same, QEMU presents itself 
> with:
> 
> .../xpack-qemu-arm-6.2.0-1/bin/qemu-system-arm --version
> xPack QEMU emulator version 6.2.0 (v6.2.0-1-xpack-arm)
> Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
> 
> All other binary xPacks (https://github.com/xpack-dev-tools/) do the same.
> 
> In my opinion, a prefix is preferred, and is consistent with the GNU 
> behaviour.

Being consistent with GNU doesn't add any functional benefit
over what we already provided, so isn't a compelling justification
IMHO.

> Anyway, having both does not break any backward compatibility and
> does not add any significant overhead/complexity.

Changing the name of the program printed by adding a prefix certainly
could cause compatibility failures. I would not be surprised to see
something looking at the --version output programatically and getting
tripped up by having a arbitrary string prefix.

If there are multiple functionally equivalent ways to achieve the same
goal, it is preferrable to pick one, rather than try to implement all
of them.

Given that we already have --with-pkgversion which satisfies the use
case, I don't see a compelling reason to add a new option. 

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 :|




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-09 Thread Liviu Ionescu



> On 9 Feb 2022, at 13:30, Peter Maydell  wrote:
> 
> gcc doesn't prepend the pkgversion string to the greeting. ...
> ... and 'gcc --version' prints the version as:
> gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Right, strictly speaking, GCC prints the program name, then the greeting 
message, then the version.

The binaries in my distribution look like this:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (xPack GNU Arm Embedded GCC x86_64) 10.3.1 20210824 (release)

$ arm-none-eabi-gdb --version
GNU gdb (xPack GNU Arm Embedded GCC x86_64) 10.2.90.20210621-git

$ riscv-none-embed-gcc --version
riscv-none-embed-gcc (xPack GNU RISC-V Embedded GCC x86_64) 10.2.0

$ clang-12 --version
xPack x86_64 clang version 12.0.1

$ openocd --version
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-17-00:18)


and similarly some other build tools:

$ gcc-xbb --version
gcc-xbb (xPack Build Box x86_64 GCC) 11.2.0

etc


> which is fairly similar to what qemu does today:
> QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.19)

which is fairly different from the more consistent:

$ qemu-system-arm --version
xPack QEMU emulator version 6.2.0 (v6.2.0-1-xpack-arm)


If you prefer the GNU scheme, we can also start with the program name, and it 
would look like:

$ qemu-system-arm --version
qemu-system-arm (xPack QEMU emulator) version 6.2.0 (v6.2.0-1-xpack-arm)

Or something like this, but applied consistently to all binaries.


Regards,

Liviu




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-09 Thread Peter Maydell
On Wed, 9 Feb 2022 at 10:13, Liviu Ionescu  wrote:
> > On 9 Feb 2022, at 11:57, Stefan Hajnoczi  wrote:
> >
> >
> > Is the existing ./configure --with-pkgversion= option not enough?
>
> My understanding of --with-pkgversion=, based on the fact that in QEMU this 
> string is appended to the version, was that it is a suffix that describes a 
> specific version.
>
> Most GNU tools, including GCC, binutils, etc, use a similar option, but the 
> string is prepended to the greeting message.

gcc doesn't prepend the pkgversion string to the greeting. Taking
the distro gcc as an example, 'gcc -v' prints out the configure options
used, which include
--with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04'

and 'gcc --version' prints the version as:
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

which is fairly similar to what qemu does today:
QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.19)

(we just have the pkgversion and the upstream version swapped).

-- PMM



Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-09 Thread Liviu Ionescu



> On 9 Feb 2022, at 11:57, Stefan Hajnoczi  wrote:
> 
> 
> Is the existing ./configure --with-pkgversion= option not enough?

My understanding of --with-pkgversion=, based on the fact that in QEMU this 
string is appended to the version, was that it is a suffix that describes a 
specific version.

Most GNU tools, including GCC, binutils, etc, use a similar option, but the 
string is prepended to the greeting message.

In my use case, --with-branding-prefix does the same, QEMU presents itself with:

.../xpack-qemu-arm-6.2.0-1/bin/qemu-system-arm --version
xPack QEMU emulator version 6.2.0 (v6.2.0-1-xpack-arm)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

All other binary xPacks (https://github.com/xpack-dev-tools/) do the same.

In my opinion, a prefix is preferred, and is consistent with the GNU behaviour.

Anyway, having both does not break any backward compatibility and does not add 
any significant overhead/complexity.


Liviu




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-09 Thread Stefan Hajnoczi
On Tue, Feb 08, 2022 at 10:39:18PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 8 Feb 2022, at 21:58, Peter Maydell  wrote:
> > 
> > I've cc'd some people who might have an opinion on whether this
> > something we want to add upstream. (Patch/thread below for context.)
> 
> Sure. For a better understanding of the reason why I found this useful: I use 
> QEMU extensively in CI tests, in various environments, and, to be sure that 
> the tests always run in a reproducible environment, I have binary packages 
> with various tools; the tested packages have dependencies on explicit 
> versions of the tools, for example:
> 
> - 
> https://github.com/micro-os-plus/micro-test-plus-xpack/blob/9c23c7d7b8fdba849602bcf8ad4c9e64e7e2837a/package.json#L505
> 
> Seeing the branded greeting in a console log is a visual confirmation that 
> the test script used the desired version, and not another version picked up 
> by mistake when using an incorrect PATH.
> 
> I hope that other distributions may find this useful too.

Is the existing ./configure --with-pkgversion= option not enough?

Here is the system QEMU from Fedora 35:

  $ qemu-system-x86_64 --version
  QEMU emulator version 6.1.0 (qemu-6.1.0-10.fc35)
 

Or on Debian:

  QEMU emulator version 5.2.0 (Debian 1:5.2+dfsg-11+deb11u1)
   

Stefan


signature.asc
Description: PGP signature


Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-08 Thread Liviu Ionescu



> On 8 Feb 2022, at 21:58, Peter Maydell  wrote:
> 
> I've cc'd some people who might have an opinion on whether this
> something we want to add upstream. (Patch/thread below for context.)

Sure. For a better understanding of the reason why I found this useful: I use 
QEMU extensively in CI tests, in various environments, and, to be sure that the 
tests always run in a reproducible environment, I have binary packages with 
various tools; the tested packages have dependencies on explicit versions of 
the tools, for example:

- 
https://github.com/micro-os-plus/micro-test-plus-xpack/blob/9c23c7d7b8fdba849602bcf8ad4c9e64e7e2837a/package.json#L505

Seeing the branded greeting in a console log is a visual confirmation that the 
test script used the desired version, and not another version picked up by 
mistake when using an incorrect PATH.

I hope that other distributions may find this useful too.

> On the actual implementation, if you make the #define expand
> out to either the empty string "" if the user specified no prefix
> or "user-specified-prefix " with a trailing space if they did,
> then you can avoid a lot of the need for ifdefs in the rest of
> the patch.

Yes, I mentioned in a previous message that I would prefer such a solution; the 
initial implementation did not rely on meson for setting this macro, so it was 
safer to use #if/#endif; later I figured out a way to configure meson to 
process the configure option, and noticed that the code would be simpler if we 
assume the definition is always present.

> Or maybe we could have a QEMU_PROG_NAME(S) macro
> that expands to S if no prefix specified or "prefix S" if there
> is one.

Sure, any better ideas will be appreciated.

> But don't respin the patch until we've decided if we
> like the concept.

Ok.

Thank you,

Liviu




Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-08 Thread Peter Maydell
On Tue, 8 Feb 2022 at 19:34, Liviu Ionescu  wrote:
>
> The 4th attempt...
>
> Not that this would be a significant patch, but I would like to proceed with 
> other improvements.

I've cc'd some people who might have an opinion on whether this
something we want to add upstream. (Patch/thread below for context.)

On the actual implementation, if you make the #define expand
out to either the empty string "" if the user specified no prefix
or "user-specified-prefix " with a trailing space if they did,
then you can avoid a lot of the need for ifdefs in the rest of
the patch. Or maybe we could have a QEMU_PROG_NAME(S) macro
that expands to S if no prefix specified or "prefix S" if there
is one. But don't respin the patch until we've decided if we
like the concept.

thanks
-- PMM

>
> > On 27 Jan 2022, at 14:23, Liviu Ionescu  wrote:
> >
> > Any chance for someone to take a look at this proposal?
> >
> > Thank you,
> >
> > Liviu
> >
> >
> >> On 20 Jan 2022, at 13:35, Liviu Ionescu  wrote:
> >>
> >> It is usual for various distributions to identify themselves by
> >> prepending a string to the greeting message, for example
> >> 'xPack QEMU emulator version 6.2.0 (v6.2.0-2-xpack-arm)'.
> >>
> >> To achieve this, a new configuration option (--with-branding-prefix=)
> >> was added, which, if not empty, adds a string preprocessor macro
> >> (QEMU_BRANDING_PREFIX) to 'config-host.h'.
> >>
> >> If this macro is defined, in QEMU and various tools, the string
> >> is displayed before the existing greeting messages.
> >> ---
> >> bsd-user/main.c  |  3 +++
> >> configure|  5 +
> >> linux-user/main.c|  3 +++
> >> meson.build  |  5 +
> >> meson_options.txt|  3 +++
> >> qemu-img.c   | 10 --
> >> qemu-io.c|  3 +++
> >> qemu-nbd.c   |  3 +++
> >> qga/main.c   |  5 -
> >> scsi/qemu-pr-helper.c|  3 +++
> >> softmmu/vl.c |  3 +++
> >> storage-daemon/qemu-storage-daemon.c |  3 +++
> >> tools/virtiofsd/passthrough_ll.c |  3 +++
> >> ui/cocoa.m   |  5 +
> >> 14 files changed, 54 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/bsd-user/main.c b/bsd-user/main.c
> >> index cb5ea40236..a4eab8feef 100644
> >> --- a/bsd-user/main.c
> >> +++ b/bsd-user/main.c
> >> @@ -149,6 +149,9 @@ void cpu_loop(CPUArchState *env)
> >>
> >> static void usage(void)
> >> {
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +printf("%s ", QEMU_BRANDING_PREFIX);
> >> +#endif
> >>printf("qemu-" TARGET_NAME " version " QEMU_FULL_VERSION
> >>   "\n" QEMU_COPYRIGHT "\n"
> >>   "usage: qemu-" TARGET_NAME " [options] program [arguments...]\n"
> >> diff --git a/configure b/configure
> >> index e1a31fb332..579a8cf55d 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -356,6 +356,7 @@ ninja=""
> >> gio="$default_feature"
> >> skip_meson=no
> >> slirp_smbd="$default_feature"
> >> +branding_prefix=""
> >>
> >> # The following Meson options are handled manually (still they
> >> # are included in the automatically generated help message)
> >> @@ -1179,6 +1180,8 @@ for opt do
> >>  # everything else has the same name in configure and meson
> >>  --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
> >>  ;;
> >> +  --with-branding-prefix=*) branding_prefix="$optarg"
> >> +  ;;
> >>  *)
> >>  echo "ERROR: unknown option $opt"
> >>  echo "Try '$0 --help' for more information"
> >> @@ -1352,6 +1355,7 @@ Advanced options (experts only):
> >>  --firmwarepath=PATH  search PATH for firmware files
> >>  --efi-aarch64=PATH   PATH of efi file to use for aarch64 VMs.
> >>  --with-suffix=SUFFIX suffix for QEMU data inside 
> >> datadir/libdir/sysconfdir/docdir [$qemu_suffix]
> >> +  --with-branding-prefix=STRING prepend string to greeting messages
> >>  --with-pkgversion=VERS   use specified string as sub-version of the 
> >> package
> >>  --without-default-features default all --enable-* options to "disabled"
> >>  --without-default-devices  do not include any device that is not needed to
> >> @@ -3810,6 +3814,7 @@ if test "$skip_meson" = no; then
> >>-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo 
> >> false; fi) \
> >>-Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
> >>-Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
> >> +-Dbranding_prefix="$branding_prefix" \
> >>$(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo 
> >> "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
> >>$(if test "$default_feature" = no; then echo 
> >> "-Dauto_features=disabled"; fi) \
> >>"$@" $cross_arg "$PWD" "$source_path"
> >> diff --git a/linux-user/main.c b/linux-user/main.c
> >> index 16def5215d..19abd1436f 100644
> >> --- a/linux-user/main.c
> >> +++ b/linux-user/main.c
> >> @@ -382,6 

Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-02-08 Thread Liviu Ionescu
The 4th attempt...

Not that this would be a significant patch, but I would like to proceed with 
other improvements.

Thank you,

Liviu


> On 27 Jan 2022, at 14:23, Liviu Ionescu  wrote:
> 
> Any chance for someone to take a look at this proposal?
> 
> Thank you,
> 
> Liviu
> 
> 
>> On 20 Jan 2022, at 13:35, Liviu Ionescu  wrote:
>> 
>> It is usual for various distributions to identify themselves by
>> prepending a string to the greeting message, for example
>> 'xPack QEMU emulator version 6.2.0 (v6.2.0-2-xpack-arm)'.
>> 
>> To achieve this, a new configuration option (--with-branding-prefix=)
>> was added, which, if not empty, adds a string preprocessor macro
>> (QEMU_BRANDING_PREFIX) to 'config-host.h'.
>> 
>> If this macro is defined, in QEMU and various tools, the string
>> is displayed before the existing greeting messages.
>> ---
>> bsd-user/main.c  |  3 +++
>> configure|  5 +
>> linux-user/main.c|  3 +++
>> meson.build  |  5 +
>> meson_options.txt|  3 +++
>> qemu-img.c   | 10 --
>> qemu-io.c|  3 +++
>> qemu-nbd.c   |  3 +++
>> qga/main.c   |  5 -
>> scsi/qemu-pr-helper.c|  3 +++
>> softmmu/vl.c |  3 +++
>> storage-daemon/qemu-storage-daemon.c |  3 +++
>> tools/virtiofsd/passthrough_ll.c |  3 +++
>> ui/cocoa.m   |  5 +
>> 14 files changed, 54 insertions(+), 3 deletions(-)
>> 
>> diff --git a/bsd-user/main.c b/bsd-user/main.c
>> index cb5ea40236..a4eab8feef 100644
>> --- a/bsd-user/main.c
>> +++ b/bsd-user/main.c
>> @@ -149,6 +149,9 @@ void cpu_loop(CPUArchState *env)
>> 
>> static void usage(void)
>> {
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>printf("qemu-" TARGET_NAME " version " QEMU_FULL_VERSION
>>   "\n" QEMU_COPYRIGHT "\n"
>>   "usage: qemu-" TARGET_NAME " [options] program [arguments...]\n"
>> diff --git a/configure b/configure
>> index e1a31fb332..579a8cf55d 100755
>> --- a/configure
>> +++ b/configure
>> @@ -356,6 +356,7 @@ ninja=""
>> gio="$default_feature"
>> skip_meson=no
>> slirp_smbd="$default_feature"
>> +branding_prefix=""
>> 
>> # The following Meson options are handled manually (still they
>> # are included in the automatically generated help message)
>> @@ -1179,6 +1180,8 @@ for opt do
>>  # everything else has the same name in configure and meson
>>  --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
>>  ;;
>> +  --with-branding-prefix=*) branding_prefix="$optarg"
>> +  ;;
>>  *)
>>  echo "ERROR: unknown option $opt"
>>  echo "Try '$0 --help' for more information"
>> @@ -1352,6 +1355,7 @@ Advanced options (experts only):
>>  --firmwarepath=PATH  search PATH for firmware files
>>  --efi-aarch64=PATH   PATH of efi file to use for aarch64 VMs.
>>  --with-suffix=SUFFIX suffix for QEMU data inside 
>> datadir/libdir/sysconfdir/docdir [$qemu_suffix]
>> +  --with-branding-prefix=STRING prepend string to greeting messages
>>  --with-pkgversion=VERS   use specified string as sub-version of the package
>>  --without-default-features default all --enable-* options to "disabled"
>>  --without-default-devices  do not include any device that is not needed to
>> @@ -3810,6 +3814,7 @@ if test "$skip_meson" = no; then
>>-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo 
>> false; fi) \
>>-Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
>>-Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
>> +-Dbranding_prefix="$branding_prefix" \
>>$(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo 
>> "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
>>$(if test "$default_feature" = no; then echo 
>> "-Dauto_features=disabled"; fi) \
>>"$@" $cross_arg "$PWD" "$source_path"
>> diff --git a/linux-user/main.c b/linux-user/main.c
>> index 16def5215d..19abd1436f 100644
>> --- a/linux-user/main.c
>> +++ b/linux-user/main.c
>> @@ -382,6 +382,9 @@ static void handle_arg_strace(const char *arg)
>> 
>> static void handle_arg_version(const char *arg)
>> {
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>printf("qemu-" TARGET_NAME " version " QEMU_FULL_VERSION
>>   "\n" QEMU_COPYRIGHT "\n");
>>exit(EXIT_SUCCESS);
>> diff --git a/meson.build b/meson.build
>> index 762d7cee85..80807a771d 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -1455,6 +1455,10 @@ 
>> config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', 
>> get_option('prefix') /
>> config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / 
>> qemu_moddir)
>> config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / 
>> get_option('sysconfdir'))
>> 
>> +if get_option('branding_prefix') != ''
>> +  

Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-01-27 Thread Liviu Ionescu
Any chance for someone to take a look at this proposal?

Thank you,

Liviu


> On 20 Jan 2022, at 13:35, Liviu Ionescu  wrote:
> 
> It is usual for various distributions to identify themselves by
> prepending a string to the greeting message, for example
> 'xPack QEMU emulator version 6.2.0 (v6.2.0-2-xpack-arm)'.
> 
> To achieve this, a new configuration option (--with-branding-prefix=)
> was added, which, if not empty, adds a string preprocessor macro
> (QEMU_BRANDING_PREFIX) to 'config-host.h'.
> 
> If this macro is defined, in QEMU and various tools, the string
> is displayed before the existing greeting messages.
> ---
> bsd-user/main.c  |  3 +++
> configure|  5 +
> linux-user/main.c|  3 +++
> meson.build  |  5 +
> meson_options.txt|  3 +++
> qemu-img.c   | 10 --
> qemu-io.c|  3 +++
> qemu-nbd.c   |  3 +++
> qga/main.c   |  5 -
> scsi/qemu-pr-helper.c|  3 +++
> softmmu/vl.c |  3 +++
> storage-daemon/qemu-storage-daemon.c |  3 +++
> tools/virtiofsd/passthrough_ll.c |  3 +++
> ui/cocoa.m   |  5 +
> 14 files changed, 54 insertions(+), 3 deletions(-)
> 
> diff --git a/bsd-user/main.c b/bsd-user/main.c
> index cb5ea40236..a4eab8feef 100644
> --- a/bsd-user/main.c
> +++ b/bsd-user/main.c
> @@ -149,6 +149,9 @@ void cpu_loop(CPUArchState *env)
> 
> static void usage(void)
> {
> +#if defined(QEMU_BRANDING_PREFIX)
> +printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
> printf("qemu-" TARGET_NAME " version " QEMU_FULL_VERSION
>"\n" QEMU_COPYRIGHT "\n"
>"usage: qemu-" TARGET_NAME " [options] program [arguments...]\n"
> diff --git a/configure b/configure
> index e1a31fb332..579a8cf55d 100755
> --- a/configure
> +++ b/configure
> @@ -356,6 +356,7 @@ ninja=""
> gio="$default_feature"
> skip_meson=no
> slirp_smbd="$default_feature"
> +branding_prefix=""
> 
> # The following Meson options are handled manually (still they
> # are included in the automatically generated help message)
> @@ -1179,6 +1180,8 @@ for opt do
>   # everything else has the same name in configure and meson
>   --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
>   ;;
> +  --with-branding-prefix=*) branding_prefix="$optarg"
> +  ;;
>   *)
>   echo "ERROR: unknown option $opt"
>   echo "Try '$0 --help' for more information"
> @@ -1352,6 +1355,7 @@ Advanced options (experts only):
>   --firmwarepath=PATH  search PATH for firmware files
>   --efi-aarch64=PATH   PATH of efi file to use for aarch64 VMs.
>   --with-suffix=SUFFIX suffix for QEMU data inside 
> datadir/libdir/sysconfdir/docdir [$qemu_suffix]
> +  --with-branding-prefix=STRING prepend string to greeting messages
>   --with-pkgversion=VERS   use specified string as sub-version of the package
>   --without-default-features default all --enable-* options to "disabled"
>   --without-default-devices  do not include any device that is not needed to
> @@ -3810,6 +3814,7 @@ if test "$skip_meson" = no; then
> -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo 
> false; fi) \
> -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
> -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
> +-Dbranding_prefix="$branding_prefix" \
> $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo 
> "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
> $(if test "$default_feature" = no; then echo 
> "-Dauto_features=disabled"; fi) \
> "$@" $cross_arg "$PWD" "$source_path"
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 16def5215d..19abd1436f 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -382,6 +382,9 @@ static void handle_arg_strace(const char *arg)
> 
> static void handle_arg_version(const char *arg)
> {
> +#if defined(QEMU_BRANDING_PREFIX)
> +printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
> printf("qemu-" TARGET_NAME " version " QEMU_FULL_VERSION
>"\n" QEMU_COPYRIGHT "\n");
> exit(EXIT_SUCCESS);
> diff --git a/meson.build b/meson.build
> index 762d7cee85..80807a771d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1455,6 +1455,10 @@ 
> config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') 
> /
> config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / 
> qemu_moddir)
> config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / 
> get_option('sysconfdir'))
> 
> +if get_option('branding_prefix') != ''
> +  config_host_data.set_quoted('QEMU_BRANDING_PREFIX', 
> get_option('branding_prefix'))
> +endif
> +
> config_host_data.set('HOST_' + host_arch.to_upper(), 1)
> 
> config_host_data.set('CONFIG_ATTR', libattr.found())
> @@ -3320,6 +3324,7 @@ endif
> summary_info += {'strip binaries':get_option('strip')}
> 

Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX

2022-01-20 Thread Liviu Ionescu



> On 20 Jan 2022, at 13:35, Liviu Ionescu  wrote:
> 
> It is usual for various distributions to identify themselves by
> prepending a string to the greeting message, for example
> 'xPack QEMU emulator version 6.2.0 (v6.2.0-2-xpack-arm)'.
> 
> To achieve this, a new configuration option (--with-branding-prefix=)
> was added, which, if not empty, adds a string preprocessor macro
> (QEMU_BRANDING_PREFIX) to 'config-host.h'.
> 
> If this macro is defined, in QEMU and various tools, the string
> is displayed before the existing greeting messages.

This proposal uses a conservative approach, and does not assume that the macro 
is always defined.

However, unless the configure process fails for an obscure reason to add 
QEMU_BRANDING_PREFIX to config-host.h, the definition should be always present; 
in this case the code using this definition can be simplified, by removing the 
#if/#endif and always inserting QEMU_BRANDING_PREFIX at the beginning of the 
string.

Any feedback will be appreciated!


Liviu