Polish the version strings containing the package version
authorThomas Huth <thuth@redhat.com>
Thu, 15 Feb 2018 11:06:47 +0000 (12:06 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 12 Mar 2018 15:12:47 +0000 (16:12 +0100)
Since commit 67a1de0d195a there is no space anymore between the
version number and the parentheses when running configure with
--with-pkgversion=foo :

 $ qemu-system-s390x --version
 QEMU emulator version 2.11.50(foo)

But the space is included when building without that option
when building from a git checkout:

 $ qemu-system-s390x --version
 QEMU emulator version 2.11.50 (v2.11.0-1494-gbec9c64-dirty)

The same confusion exists with the "query-version" QMP command.
Let's fix this by introducing a proper QEMU_FULL_VERSION definition
that includes the space and parentheses, while the QEMU_PKGVERSION
should just cleanly contain the package version string itself.
Note that this also changes the behavior of the "query-version" QMP
command (the space and parentheses are not included there anymore),
but that's supposed to be OK since the strings there are not meant
to be parsed by other tools.

Fixes: 67a1de0d195a6185c39b436159c9ffc7720bf979
Buglink: https://bugs.launchpad.net/qemu/+bug/1673373
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1518692807-25859-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Makefile
bsd-user/main.c
configure
linux-user/main.c
qemu-img.c
qemu-io.c
qemu-nbd.c
qga/main.c
scsi/qemu-pr-helper.c
ui/cocoa.m
vl.c

index 5d9ef3b8fd58e432d9ae0dd6225bf9abc0b66821..416a81c7caa8ef416172fe2736b8e275cf7bec23 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -434,21 +434,23 @@ all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 qemu-version.h: FORCE
        $(call quiet-command, \
                (cd $(SRC_PATH); \
-               printf '#define QEMU_PKGVERSION '; \
                if test -n "$(PKGVERSION)"; then \
-                       printf '"$(PKGVERSION)"\n'; \
+                       pkgvers="$(PKGVERSION)"; \
                else \
                        if test -d .git; then \
-                               printf '" ('; \
-                               git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
+                               pkgvers=$$(git describe --match 'v*' 2>/dev/null | tr -d '\n');\
                                if ! git diff-index --quiet HEAD &>/dev/null; then \
-                                       printf -- '-dirty'; \
+                                       pkgvers="$${pkgvers}-dirty"; \
                                fi; \
-                               printf ')"\n'; \
-                       else \
-                               printf '""\n'; \
                        fi; \
-               fi) > $@.tmp)
+               fi; \
+               printf "#define QEMU_PKGVERSION \"$${pkgvers}\"\n"; \
+               if test -n "$${pkgvers}"; then \
+                       printf '#define QEMU_FULL_VERSION QEMU_VERSION " (" QEMU_PKGVERSION ")"\n'; \
+               else \
+                       printf '#define QEMU_FULL_VERSION QEMU_VERSION\n'; \
+               fi; \
+               ) > $@.tmp)
        $(call quiet-command, if ! cmp -s $@ $@.tmp; then \
          mv $@.tmp $@; \
         else \
index efef5ff8c506efe5e587724e145edb4e2689249d..05aa5594a9e23fdb3bb26a51cf600d46d349ef1b 100644 (file)
@@ -649,7 +649,7 @@ void cpu_loop(CPUSPARCState *env)
 
 static void usage(void)
 {
-    printf("qemu-" TARGET_NAME " version " QEMU_VERSION QEMU_PKGVERSION
+    printf("qemu-" TARGET_NAME " version " QEMU_FULL_VERSION
            "\n" QEMU_COPYRIGHT "\n"
            "usage: qemu-" TARGET_NAME " [options] program [arguments...]\n"
            "BSD CPU emulator (compiled for %s emulation)\n"
index f74e1f3b7cce0a5c4f56a48d0a8a7d65c3b55dd7..26d56eb5bb93b52036bb8281c4d26fae211508fa 100755 (executable)
--- a/configure
+++ b/configure
@@ -1163,7 +1163,7 @@ for opt do
   ;;
   --disable-blobs) blobs="no"
   ;;
-  --with-pkgversion=*) pkgversion=" ($optarg)"
+  --with-pkgversion=*) pkgversion="$optarg"
   ;;
   --with-coroutine=*) coroutine="$optarg"
   ;;
index 7bc9bc79b052e389c40dc2bb22e8527939816403..abbd14e2088ad0e19ce8561f870747bbcb4b87f6 100644 (file)
@@ -4163,7 +4163,7 @@ static void handle_arg_strace(const char *arg)
 
 static void handle_arg_version(const char *arg)
 {
-    printf("qemu-" TARGET_NAME " version " QEMU_VERSION QEMU_PKGVERSION
+    printf("qemu-" TARGET_NAME " version " QEMU_FULL_VERSION
            "\n" QEMU_COPYRIGHT "\n");
     exit(EXIT_SUCCESS);
 }
index 088d89043e925fbceda9745dc777c1ab49fb2f0c..855fa525141452e50230d70a49ef89edb2909378 100644 (file)
@@ -46,7 +46,7 @@
 #include "crypto/init.h"
 #include "trace/control.h"
 
-#define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION QEMU_PKGVERSION \
+#define QEMU_IMG_VERSION "qemu-img version " QEMU_FULL_VERSION \
                           "\n" QEMU_COPYRIGHT "\n"
 
 typedef struct img_cmd_t {
index 160fb2a89f7db3cd45482c43f9be4e277eb9f376..e692c555e05d7fac139c0f0c0bd1fae1c9afcf01 100644 (file)
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -558,7 +558,7 @@ int main(int argc, char **argv)
             trace_file = trace_opt_parse(optarg);
             break;
         case 'V':
-            printf("%s version " QEMU_VERSION QEMU_PKGVERSION "\n"
+            printf("%s version " QEMU_FULL_VERSION "\n"
                    QEMU_COPYRIGHT "\n", progname);
             exit(0);
         case 'h':
index ed5d9b5062629028a79f879c5ef180507a41a013..0af0560ad1c65fa6d67b66e57e747849ce4f9979 100644 (file)
@@ -130,7 +130,7 @@ QEMU_HELP_BOTTOM "\n"
 static void version(const char *name)
 {
     printf(
-"%s " QEMU_VERSION QEMU_PKGVERSION "\n"
+"%s " QEMU_FULL_VERSION "\n"
 "Written by Anthony Liguori.\n"
 "\n"
 QEMU_COPYRIGHT "\n"
index f9c83050c5daeae890dd9f2c0131341d41ca0b94..837a75a46a1c92faa136ea63d6521ec26fef9ba0 100644 (file)
@@ -218,7 +218,7 @@ static void usage(const char *cmd)
 {
     printf(
 "Usage: %s [-m <method> -p <path>] [<options>]\n"
-"QEMU Guest Agent " QEMU_VERSION QEMU_PKGVERSION "\n"
+"QEMU Guest Agent " QEMU_FULL_VERSION "\n"
 QEMU_COPYRIGHT "\n"
 "\n"
 "  -m, --method      transport method: one of unix-listen, virtio-serial,\n"
index 9fe615c73c7c49958c7bdee0c629288ce1dde49c..3facbba17080e63b4554214a405542d038a39792 100644 (file)
@@ -102,7 +102,7 @@ QEMU_HELP_BOTTOM "\n"
 static void version(const char *name)
 {
     printf(
-"%s " QEMU_VERSION QEMU_PKGVERSION "\n"
+"%s " QEMU_FULL_VERSION "\n"
 "Written by Paolo Bonzini.\n"
 "\n"
 QEMU_COPYRIGHT "\n"
index 18de0bb3eaa1debfd0610d22e8e58673941606ba..110b393e4e7b92907a5887102298fbb14a0595ff 100644 (file)
@@ -1330,7 +1330,7 @@ QemuCocoaView *cocoaView;
     /* Create the version string*/
     NSString *version_string;
     version_string = [[NSString alloc] initWithFormat:
-    @"QEMU emulator version %s%s", QEMU_VERSION, QEMU_PKGVERSION];
+    @"QEMU emulator version %s", QEMU_FULL_VERSION];
     [version_label setStringValue: version_string];
     [superView addSubview: version_label];
 
diff --git a/vl.c b/vl.c
index 26662eb9e7682404ac6815722d7e2f7831cd328c..e81152417a541c91d3c7fea5406d3000b93f9dab 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1948,7 +1948,7 @@ static void main_loop(void)
 
 static void version(void)
 {
-    printf("QEMU emulator version " QEMU_VERSION QEMU_PKGVERSION "\n"
+    printf("QEMU emulator version " QEMU_FULL_VERSION "\n"
            QEMU_COPYRIGHT "\n");
 }