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

Liviu Ionescu posted 1 patch 2 years, 2 months ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220120113545.55820-1-ilg@livius.net
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Fam Zheng <fam@euphon.net>, Paolo Bonzini <pbonzini@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Eric Blake <eblake@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, Kyle Evans <kevans@freebsd.org>, Laurent Vivier <laurent@vivier.eu>, Stefan Hajnoczi <stefanha@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Michael Roth <michael.roth@amd.com>, Warner Losh <imp@bsdimp.com>
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(-)
[PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX
Posted by Liviu Ionescu 2 years, 2 months ago
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')}
 summary_info += {'sparse':            sparse}
 summary_info += {'mingw32 support':   targetos == 'windows'}
+summary_info += {'branding prefix':   get_option('branding_prefix')}
 
 # snarf the cross-compilation information for tests
 foreach target: target_dirs
diff --git a/meson_options.txt b/meson_options.txt
index 921967eddb..be044cc1e6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -208,3 +208,6 @@ option('fdt', type: 'combo', value: 'auto',
 
 option('selinux', type: 'feature', value: 'auto',
        description: 'SELinux support in qemu-nbd')
+
+option('branding_prefix', type: 'string', value: '',
+       description: 'String to prepend to greeting messages')
diff --git a/qemu-img.c b/qemu-img.c
index 6fe2466032..c10c0066e5 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -52,8 +52,14 @@
 #include "qemu/throttle.h"
 #include "block/throttle-groups.h"
 
+#if defined(QEMU_BRANDING_PREFIX)
+#define QEMU_IMG_VERSION QEMU_BRANDING_PREFIX " qemu-img version " \
+                         QEMU_FULL_VERSION \
+                         "\n" QEMU_COPYRIGHT "\n"
+#else
 #define QEMU_IMG_VERSION "qemu-img version " QEMU_FULL_VERSION \
-                          "\n" QEMU_COPYRIGHT "\n"
+                         "\n" QEMU_COPYRIGHT "\n"
+#endif
 
 typedef struct img_cmd_t {
     const char *name;
@@ -235,7 +241,7 @@ static void QEMU_NORETURN help(void)
  * an odd number of ',' (or else a separating ',' following it gets
  * escaped), or be empty (or else a separating ',' preceding it can
  * escape a separating ',' following it).
- * 
+ *
  */
 static bool is_valid_option_list(const char *optarg)
 {
diff --git a/qemu-io.c b/qemu-io.c
index 3924639b92..ec880dc49e 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -597,6 +597,9 @@ int main(int argc, char **argv)
             trace_opt_parse(optarg);
             break;
         case 'V':
+#if defined(QEMU_BRANDING_PREFIX)
+            printf("%s ", QEMU_BRANDING_PREFIX);
+#endif
             printf("%s version " QEMU_FULL_VERSION "\n"
                    QEMU_COPYRIGHT "\n", error_get_progname());
             exit(0);
diff --git a/qemu-nbd.c b/qemu-nbd.c
index c6c20df68a..7b3667626c 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -157,6 +157,9 @@ QEMU_HELP_BOTTOM "\n"
 
 static void version(const char *name)
 {
+#if defined(QEMU_BRANDING_PREFIX)
+    printf("%s ", QEMU_BRANDING_PREFIX);
+#endif
     printf(
 "%s " QEMU_FULL_VERSION "\n"
 "Written by Anthony Liguori.\n"
diff --git a/qga/main.c b/qga/main.c
index 15fd3a4149..c66b87f72c 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -224,8 +224,11 @@ void reopen_fd_to_null(int fd)
 
 static void usage(const char *cmd)
 {
+    printf("Usage: %s [-m <method> -p <path>] [<options>]\n");
+#if defined(QEMU_BRANDING_PREFIX)
+    printf("%s ", QEMU_BRANDING_PREFIX);
+#endif
     printf(
-"Usage: %s [-m <method> -p <path>] [<options>]\n"
 "QEMU Guest Agent " QEMU_FULL_VERSION "\n"
 QEMU_COPYRIGHT "\n"
 "\n"
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index f281daeced..d7fcdb8216 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -108,6 +108,9 @@ QEMU_HELP_BOTTOM "\n"
 
 static void version(const char *name)
 {
+#if defined(QEMU_BRANDING_PREFIX)
+    printf("%s ", QEMU_BRANDING_PREFIX);
+#endif
     printf(
 "%s " QEMU_FULL_VERSION "\n"
 "Written by Paolo Bonzini.\n"
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 5e1b35ba48..d83118d939 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -826,6 +826,9 @@ static MachineClass *find_default_machine(GSList *machines)
 
 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");
 }
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index 9d76d1114d..1a8de7c59d 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -212,6 +212,9 @@ static void process_options(int argc, char *argv[])
             trace_init_file();
             break;
         case 'V':
+#if defined(QEMU_BRANDING_PREFIX)
+            printf("%s ", QEMU_BRANDING_PREFIX);
+#endif
             printf("qemu-storage-daemon version "
                    QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
             exit(EXIT_SUCCESS);
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 64b5b4fbb1..2179a502d6 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -3896,6 +3896,9 @@ static void fuse_lo_data_cleanup(struct lo_data *lo)
 
 static void qemu_version(void)
 {
+#if defined(QEMU_BRANDING_PREFIX)
+    printf("%s ", QEMU_BRANDING_PREFIX);
+#endif
     printf("virtiofsd version " QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
 }
 
diff --git a/ui/cocoa.m b/ui/cocoa.m
index ac18e14ce0..5a1e56ac46 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1524,8 +1524,13 @@ - (void)make_about_window
 
     /* Create the version string*/
     NSString *version_string;
+#if defined(QEMU_BRANDING_PREFIX)
+    version_string = [[NSString alloc] initWithFormat:
+    @"%s QEMU emulator version %s", QEMU_BRANDING_PREFIX, QEMU_FULL_VERSION];
+#else
     version_string = [[NSString alloc] initWithFormat:
     @"QEMU emulator version %s", QEMU_FULL_VERSION];
+#endif
     [version_label setStringValue: version_string];
     [superView addSubview: version_label];
 
-- 
2.32.0 (Apple Git-132)


Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX
Posted by Liviu Ionescu 2 years, 2 months ago

> On 20 Jan 2022, at 13:35, Liviu Ionescu <ilg@livius.net> 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


Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX
Posted by Liviu Ionescu 2 years, 2 months ago
Any chance for someone to take a look at this proposal?

Thank you,

Liviu


> On 20 Jan 2022, at 13:35, Liviu Ionescu <ilg@livius.net> 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')}
> summary_info += {'sparse':            sparse}
> summary_info += {'mingw32 support':   targetos == 'windows'}
> +summary_info += {'branding prefix':   get_option('branding_prefix')}
> 
> # snarf the cross-compilation information for tests
> foreach target: target_dirs
> diff --git a/meson_options.txt b/meson_options.txt
> index 921967eddb..be044cc1e6 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -208,3 +208,6 @@ option('fdt', type: 'combo', value: 'auto',
> 
> option('selinux', type: 'feature', value: 'auto',
>        description: 'SELinux support in qemu-nbd')
> +
> +option('branding_prefix', type: 'string', value: '',
> +       description: 'String to prepend to greeting messages')
> diff --git a/qemu-img.c b/qemu-img.c
> index 6fe2466032..c10c0066e5 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -52,8 +52,14 @@
> #include "qemu/throttle.h"
> #include "block/throttle-groups.h"
> 
> +#if defined(QEMU_BRANDING_PREFIX)
> +#define QEMU_IMG_VERSION QEMU_BRANDING_PREFIX " qemu-img version " \
> +                         QEMU_FULL_VERSION \
> +                         "\n" QEMU_COPYRIGHT "\n"
> +#else
> #define QEMU_IMG_VERSION "qemu-img version " QEMU_FULL_VERSION \
> -                          "\n" QEMU_COPYRIGHT "\n"
> +                         "\n" QEMU_COPYRIGHT "\n"
> +#endif
> 
> typedef struct img_cmd_t {
>     const char *name;
> @@ -235,7 +241,7 @@ static void QEMU_NORETURN help(void)
>  * an odd number of ',' (or else a separating ',' following it gets
>  * escaped), or be empty (or else a separating ',' preceding it can
>  * escape a separating ',' following it).
> - * 
> + *
>  */
> static bool is_valid_option_list(const char *optarg)
> {
> diff --git a/qemu-io.c b/qemu-io.c
> index 3924639b92..ec880dc49e 100644
> --- a/qemu-io.c
> +++ b/qemu-io.c
> @@ -597,6 +597,9 @@ int main(int argc, char **argv)
>             trace_opt_parse(optarg);
>             break;
>         case 'V':
> +#if defined(QEMU_BRANDING_PREFIX)
> +            printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
>             printf("%s version " QEMU_FULL_VERSION "\n"
>                    QEMU_COPYRIGHT "\n", error_get_progname());
>             exit(0);
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index c6c20df68a..7b3667626c 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -157,6 +157,9 @@ QEMU_HELP_BOTTOM "\n"
> 
> static void version(const char *name)
> {
> +#if defined(QEMU_BRANDING_PREFIX)
> +    printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
>     printf(
> "%s " QEMU_FULL_VERSION "\n"
> "Written by Anthony Liguori.\n"
> diff --git a/qga/main.c b/qga/main.c
> index 15fd3a4149..c66b87f72c 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -224,8 +224,11 @@ void reopen_fd_to_null(int fd)
> 
> static void usage(const char *cmd)
> {
> +    printf("Usage: %s [-m <method> -p <path>] [<options>]\n");
> +#if defined(QEMU_BRANDING_PREFIX)
> +    printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
>     printf(
> -"Usage: %s [-m <method> -p <path>] [<options>]\n"
> "QEMU Guest Agent " QEMU_FULL_VERSION "\n"
> QEMU_COPYRIGHT "\n"
> "\n"
> diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
> index f281daeced..d7fcdb8216 100644
> --- a/scsi/qemu-pr-helper.c
> +++ b/scsi/qemu-pr-helper.c
> @@ -108,6 +108,9 @@ QEMU_HELP_BOTTOM "\n"
> 
> static void version(const char *name)
> {
> +#if defined(QEMU_BRANDING_PREFIX)
> +    printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
>     printf(
> "%s " QEMU_FULL_VERSION "\n"
> "Written by Paolo Bonzini.\n"
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 5e1b35ba48..d83118d939 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -826,6 +826,9 @@ static MachineClass *find_default_machine(GSList *machines)
> 
> 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");
> }
> diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
> index 9d76d1114d..1a8de7c59d 100644
> --- a/storage-daemon/qemu-storage-daemon.c
> +++ b/storage-daemon/qemu-storage-daemon.c
> @@ -212,6 +212,9 @@ static void process_options(int argc, char *argv[])
>             trace_init_file();
>             break;
>         case 'V':
> +#if defined(QEMU_BRANDING_PREFIX)
> +            printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
>             printf("qemu-storage-daemon version "
>                    QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
>             exit(EXIT_SUCCESS);
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 64b5b4fbb1..2179a502d6 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -3896,6 +3896,9 @@ static void fuse_lo_data_cleanup(struct lo_data *lo)
> 
> static void qemu_version(void)
> {
> +#if defined(QEMU_BRANDING_PREFIX)
> +    printf("%s ", QEMU_BRANDING_PREFIX);
> +#endif
>     printf("virtiofsd version " QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
> }
> 
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index ac18e14ce0..5a1e56ac46 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -1524,8 +1524,13 @@ - (void)make_about_window
> 
>     /* Create the version string*/
>     NSString *version_string;
> +#if defined(QEMU_BRANDING_PREFIX)
> +    version_string = [[NSString alloc] initWithFormat:
> +    @"%s QEMU emulator version %s", QEMU_BRANDING_PREFIX, QEMU_FULL_VERSION];
> +#else
>     version_string = [[NSString alloc] initWithFormat:
>     @"QEMU emulator version %s", QEMU_FULL_VERSION];
> +#endif
>     [version_label setStringValue: version_string];
>     [superView addSubview: version_label];
> 
> -- 
> 2.32.0 (Apple Git-132)
> 


Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX
Posted by Liviu Ionescu 2 years, 1 month ago
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 <ilg@livius.net> wrote:
> 
> Any chance for someone to take a look at this proposal?
> 
> Thank you,
> 
> Liviu
> 
> 
>> On 20 Jan 2022, at 13:35, Liviu Ionescu <ilg@livius.net> 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')}
>> summary_info += {'sparse':            sparse}
>> summary_info += {'mingw32 support':   targetos == 'windows'}
>> +summary_info += {'branding prefix':   get_option('branding_prefix')}
>> 
>> # snarf the cross-compilation information for tests
>> foreach target: target_dirs
>> diff --git a/meson_options.txt b/meson_options.txt
>> index 921967eddb..be044cc1e6 100644
>> --- a/meson_options.txt
>> +++ b/meson_options.txt
>> @@ -208,3 +208,6 @@ option('fdt', type: 'combo', value: 'auto',
>> 
>> option('selinux', type: 'feature', value: 'auto',
>>       description: 'SELinux support in qemu-nbd')
>> +
>> +option('branding_prefix', type: 'string', value: '',
>> +       description: 'String to prepend to greeting messages')
>> diff --git a/qemu-img.c b/qemu-img.c
>> index 6fe2466032..c10c0066e5 100644
>> --- a/qemu-img.c
>> +++ b/qemu-img.c
>> @@ -52,8 +52,14 @@
>> #include "qemu/throttle.h"
>> #include "block/throttle-groups.h"
>> 
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +#define QEMU_IMG_VERSION QEMU_BRANDING_PREFIX " qemu-img version " \
>> +                         QEMU_FULL_VERSION \
>> +                         "\n" QEMU_COPYRIGHT "\n"
>> +#else
>> #define QEMU_IMG_VERSION "qemu-img version " QEMU_FULL_VERSION \
>> -                          "\n" QEMU_COPYRIGHT "\n"
>> +                         "\n" QEMU_COPYRIGHT "\n"
>> +#endif
>> 
>> typedef struct img_cmd_t {
>>    const char *name;
>> @@ -235,7 +241,7 @@ static void QEMU_NORETURN help(void)
>> * an odd number of ',' (or else a separating ',' following it gets
>> * escaped), or be empty (or else a separating ',' preceding it can
>> * escape a separating ',' following it).
>> - * 
>> + *
>> */
>> static bool is_valid_option_list(const char *optarg)
>> {
>> diff --git a/qemu-io.c b/qemu-io.c
>> index 3924639b92..ec880dc49e 100644
>> --- a/qemu-io.c
>> +++ b/qemu-io.c
>> @@ -597,6 +597,9 @@ int main(int argc, char **argv)
>>            trace_opt_parse(optarg);
>>            break;
>>        case 'V':
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +            printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>            printf("%s version " QEMU_FULL_VERSION "\n"
>>                   QEMU_COPYRIGHT "\n", error_get_progname());
>>            exit(0);
>> diff --git a/qemu-nbd.c b/qemu-nbd.c
>> index c6c20df68a..7b3667626c 100644
>> --- a/qemu-nbd.c
>> +++ b/qemu-nbd.c
>> @@ -157,6 +157,9 @@ QEMU_HELP_BOTTOM "\n"
>> 
>> static void version(const char *name)
>> {
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +    printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>    printf(
>> "%s " QEMU_FULL_VERSION "\n"
>> "Written by Anthony Liguori.\n"
>> diff --git a/qga/main.c b/qga/main.c
>> index 15fd3a4149..c66b87f72c 100644
>> --- a/qga/main.c
>> +++ b/qga/main.c
>> @@ -224,8 +224,11 @@ void reopen_fd_to_null(int fd)
>> 
>> static void usage(const char *cmd)
>> {
>> +    printf("Usage: %s [-m <method> -p <path>] [<options>]\n");
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +    printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>    printf(
>> -"Usage: %s [-m <method> -p <path>] [<options>]\n"
>> "QEMU Guest Agent " QEMU_FULL_VERSION "\n"
>> QEMU_COPYRIGHT "\n"
>> "\n"
>> diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
>> index f281daeced..d7fcdb8216 100644
>> --- a/scsi/qemu-pr-helper.c
>> +++ b/scsi/qemu-pr-helper.c
>> @@ -108,6 +108,9 @@ QEMU_HELP_BOTTOM "\n"
>> 
>> static void version(const char *name)
>> {
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +    printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>    printf(
>> "%s " QEMU_FULL_VERSION "\n"
>> "Written by Paolo Bonzini.\n"
>> diff --git a/softmmu/vl.c b/softmmu/vl.c
>> index 5e1b35ba48..d83118d939 100644
>> --- a/softmmu/vl.c
>> +++ b/softmmu/vl.c
>> @@ -826,6 +826,9 @@ static MachineClass *find_default_machine(GSList *machines)
>> 
>> 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");
>> }
>> diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
>> index 9d76d1114d..1a8de7c59d 100644
>> --- a/storage-daemon/qemu-storage-daemon.c
>> +++ b/storage-daemon/qemu-storage-daemon.c
>> @@ -212,6 +212,9 @@ static void process_options(int argc, char *argv[])
>>            trace_init_file();
>>            break;
>>        case 'V':
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +            printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>            printf("qemu-storage-daemon version "
>>                   QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
>>            exit(EXIT_SUCCESS);
>> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
>> index 64b5b4fbb1..2179a502d6 100644
>> --- a/tools/virtiofsd/passthrough_ll.c
>> +++ b/tools/virtiofsd/passthrough_ll.c
>> @@ -3896,6 +3896,9 @@ static void fuse_lo_data_cleanup(struct lo_data *lo)
>> 
>> static void qemu_version(void)
>> {
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +    printf("%s ", QEMU_BRANDING_PREFIX);
>> +#endif
>>    printf("virtiofsd version " QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
>> }
>> 
>> diff --git a/ui/cocoa.m b/ui/cocoa.m
>> index ac18e14ce0..5a1e56ac46 100644
>> --- a/ui/cocoa.m
>> +++ b/ui/cocoa.m
>> @@ -1524,8 +1524,13 @@ - (void)make_about_window
>> 
>>    /* Create the version string*/
>>    NSString *version_string;
>> +#if defined(QEMU_BRANDING_PREFIX)
>> +    version_string = [[NSString alloc] initWithFormat:
>> +    @"%s QEMU emulator version %s", QEMU_BRANDING_PREFIX, QEMU_FULL_VERSION];
>> +#else
>>    version_string = [[NSString alloc] initWithFormat:
>>    @"QEMU emulator version %s", QEMU_FULL_VERSION];
>> +#endif
>>    [version_label setStringValue: version_string];
>>    [superView addSubview: version_label];
>> 
>> -- 
>> 2.32.0 (Apple Git-132)
>> 
> 


Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX
Posted by Peter Maydell 2 years, 1 month ago
On Tue, 8 Feb 2022 at 19:34, Liviu Ionescu <ilg@livius.net> 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 <ilg@livius.net> wrote:
> >
> > Any chance for someone to take a look at this proposal?
> >
> > Thank you,
> >
> > Liviu
> >
> >
> >> On 20 Jan 2022, at 13:35, Liviu Ionescu <ilg@livius.net> 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')}
> >> summary_info += {'sparse':            sparse}
> >> summary_info += {'mingw32 support':   targetos == 'windows'}
> >> +summary_info += {'branding prefix':   get_option('branding_prefix')}
> >>
> >> # snarf the cross-compilation information for tests
> >> foreach target: target_dirs
> >> diff --git a/meson_options.txt b/meson_options.txt
> >> index 921967eddb..be044cc1e6 100644
> >> --- a/meson_options.txt
> >> +++ b/meson_options.txt
> >> @@ -208,3 +208,6 @@ option('fdt', type: 'combo', value: 'auto',
> >>
> >> option('selinux', type: 'feature', value: 'auto',
> >>       description: 'SELinux support in qemu-nbd')
> >> +
> >> +option('branding_prefix', type: 'string', value: '',
> >> +       description: 'String to prepend to greeting messages')
> >> diff --git a/qemu-img.c b/qemu-img.c
> >> index 6fe2466032..c10c0066e5 100644
> >> --- a/qemu-img.c
> >> +++ b/qemu-img.c
> >> @@ -52,8 +52,14 @@
> >> #include "qemu/throttle.h"
> >> #include "block/throttle-groups.h"
> >>
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +#define QEMU_IMG_VERSION QEMU_BRANDING_PREFIX " qemu-img version " \
> >> +                         QEMU_FULL_VERSION \
> >> +                         "\n" QEMU_COPYRIGHT "\n"
> >> +#else
> >> #define QEMU_IMG_VERSION "qemu-img version " QEMU_FULL_VERSION \
> >> -                          "\n" QEMU_COPYRIGHT "\n"
> >> +                         "\n" QEMU_COPYRIGHT "\n"
> >> +#endif
> >>
> >> typedef struct img_cmd_t {
> >>    const char *name;
> >> @@ -235,7 +241,7 @@ static void QEMU_NORETURN help(void)
> >> * an odd number of ',' (or else a separating ',' following it gets
> >> * escaped), or be empty (or else a separating ',' preceding it can
> >> * escape a separating ',' following it).
> >> - *
> >> + *
> >> */
> >> static bool is_valid_option_list(const char *optarg)
> >> {
> >> diff --git a/qemu-io.c b/qemu-io.c
> >> index 3924639b92..ec880dc49e 100644
> >> --- a/qemu-io.c
> >> +++ b/qemu-io.c
> >> @@ -597,6 +597,9 @@ int main(int argc, char **argv)
> >>            trace_opt_parse(optarg);
> >>            break;
> >>        case 'V':
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +            printf("%s ", QEMU_BRANDING_PREFIX);
> >> +#endif
> >>            printf("%s version " QEMU_FULL_VERSION "\n"
> >>                   QEMU_COPYRIGHT "\n", error_get_progname());
> >>            exit(0);
> >> diff --git a/qemu-nbd.c b/qemu-nbd.c
> >> index c6c20df68a..7b3667626c 100644
> >> --- a/qemu-nbd.c
> >> +++ b/qemu-nbd.c
> >> @@ -157,6 +157,9 @@ QEMU_HELP_BOTTOM "\n"
> >>
> >> static void version(const char *name)
> >> {
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +    printf("%s ", QEMU_BRANDING_PREFIX);
> >> +#endif
> >>    printf(
> >> "%s " QEMU_FULL_VERSION "\n"
> >> "Written by Anthony Liguori.\n"
> >> diff --git a/qga/main.c b/qga/main.c
> >> index 15fd3a4149..c66b87f72c 100644
> >> --- a/qga/main.c
> >> +++ b/qga/main.c
> >> @@ -224,8 +224,11 @@ void reopen_fd_to_null(int fd)
> >>
> >> static void usage(const char *cmd)
> >> {
> >> +    printf("Usage: %s [-m <method> -p <path>] [<options>]\n");
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +    printf("%s ", QEMU_BRANDING_PREFIX);
> >> +#endif
> >>    printf(
> >> -"Usage: %s [-m <method> -p <path>] [<options>]\n"
> >> "QEMU Guest Agent " QEMU_FULL_VERSION "\n"
> >> QEMU_COPYRIGHT "\n"
> >> "\n"
> >> diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
> >> index f281daeced..d7fcdb8216 100644
> >> --- a/scsi/qemu-pr-helper.c
> >> +++ b/scsi/qemu-pr-helper.c
> >> @@ -108,6 +108,9 @@ QEMU_HELP_BOTTOM "\n"
> >>
> >> static void version(const char *name)
> >> {
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +    printf("%s ", QEMU_BRANDING_PREFIX);
> >> +#endif
> >>    printf(
> >> "%s " QEMU_FULL_VERSION "\n"
> >> "Written by Paolo Bonzini.\n"
> >> diff --git a/softmmu/vl.c b/softmmu/vl.c
> >> index 5e1b35ba48..d83118d939 100644
> >> --- a/softmmu/vl.c
> >> +++ b/softmmu/vl.c
> >> @@ -826,6 +826,9 @@ static MachineClass *find_default_machine(GSList *machines)
> >>
> >> 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");
> >> }
> >> diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
> >> index 9d76d1114d..1a8de7c59d 100644
> >> --- a/storage-daemon/qemu-storage-daemon.c
> >> +++ b/storage-daemon/qemu-storage-daemon.c
> >> @@ -212,6 +212,9 @@ static void process_options(int argc, char *argv[])
> >>            trace_init_file();
> >>            break;
> >>        case 'V':
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +            printf("%s ", QEMU_BRANDING_PREFIX);
> >> +#endif
> >>            printf("qemu-storage-daemon version "
> >>                   QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
> >>            exit(EXIT_SUCCESS);
> >> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> >> index 64b5b4fbb1..2179a502d6 100644
> >> --- a/tools/virtiofsd/passthrough_ll.c
> >> +++ b/tools/virtiofsd/passthrough_ll.c
> >> @@ -3896,6 +3896,9 @@ static void fuse_lo_data_cleanup(struct lo_data *lo)
> >>
> >> static void qemu_version(void)
> >> {
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +    printf("%s ", QEMU_BRANDING_PREFIX);
> >> +#endif
> >>    printf("virtiofsd version " QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
> >> }
> >>
> >> diff --git a/ui/cocoa.m b/ui/cocoa.m
> >> index ac18e14ce0..5a1e56ac46 100644
> >> --- a/ui/cocoa.m
> >> +++ b/ui/cocoa.m
> >> @@ -1524,8 +1524,13 @@ - (void)make_about_window
> >>
> >>    /* Create the version string*/
> >>    NSString *version_string;
> >> +#if defined(QEMU_BRANDING_PREFIX)
> >> +    version_string = [[NSString alloc] initWithFormat:
> >> +    @"%s QEMU emulator version %s", QEMU_BRANDING_PREFIX, QEMU_FULL_VERSION];
> >> +#else
> >>    version_string = [[NSString alloc] initWithFormat:
> >>    @"QEMU emulator version %s", QEMU_FULL_VERSION];
> >> +#endif
> >>    [version_label setStringValue: version_string];
> >>    [superView addSubview: version_label];
> >>
> >> --
> >> 2.32.0 (Apple Git-132)
> >>
> >
>

Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX
Posted by Liviu Ionescu 2 years, 1 month ago

> On 8 Feb 2022, at 21:58, Peter Maydell <peter.maydell@linaro.org> 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
Posted by Peter Maydell 2 years, 1 month ago
On Mon, 14 Feb 2022 at 11:54, Liviu Ionescu <ilg@livius.net> 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
Posted by Liviu Ionescu 2 years, 1 month ago

> On 14 Feb 2022, at 14:06, Peter Maydell <peter.maydell@linaro.org> 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
Posted by Daniel P. Berrangé 2 years, 1 month ago
On Mon, Feb 14, 2022 at 02:18:13PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 14 Feb 2022, at 14:06, Peter Maydell <peter.maydell@linaro.org> 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
Posted by Liviu Ionescu 2 years, 1 month ago

> On 14 Feb 2022, at 14:28, Daniel P. Berrangé <berrange@redhat.com> 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
Posted by Peter Maydell 2 years, 1 month ago
On Mon, 14 Feb 2022 at 13:06, Liviu Ionescu <ilg@livius.net> wrote:
>
>
>
> > On 14 Feb 2022, at 14:28, Daniel P. Berrangé <berrange@redhat.com> 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
Posted by Daniel P. Berrangé 2 years, 1 month ago
On Mon, Feb 14, 2022 at 03:05:58PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 14 Feb 2022, at 14:28, Daniel P. Berrangé <berrange@redhat.com> 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
Posted by Liviu Ionescu 2 years, 1 month ago

> On 8 Feb 2022, at 21:58, Peter Maydell <peter.maydell@linaro.org> 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
Posted by Stefan Hajnoczi 2 years, 1 month ago
On Tue, Feb 08, 2022 at 10:39:18PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 8 Feb 2022, at 21:58, Peter Maydell <peter.maydell@linaro.org> 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
Re: [PATCH] Add --with-branding-prefix and QEMU_BRANDING_PREFIX
Posted by Liviu Ionescu 2 years, 1 month ago

> On 9 Feb 2022, at 11:57, Stefan Hajnoczi <stefanha@redhat.com> 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
Posted by Peter Maydell 2 years, 1 month ago
On Wed, 9 Feb 2022 at 10:13, Liviu Ionescu <ilg@livius.net> wrote:
> > On 9 Feb 2022, at 11:57, Stefan Hajnoczi <stefanha@redhat.com> 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
Posted by Liviu Ionescu 2 years, 1 month ago

> On 9 Feb 2022, at 13:30, Peter Maydell <peter.maydell@linaro.org> 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
Posted by Daniel P. Berrangé 2 years, 1 month ago
On Wed, Feb 09, 2022 at 12:13:02PM +0200, Liviu Ionescu wrote:
> 
> 
> > On 9 Feb 2022, at 11:57, Stefan Hajnoczi <stefanha@redhat.com> 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 :|