* [Qemu-devel] including the "git describe" output in the QEMU binaries? @ 2016-05-31 11:16 Laszlo Ersek 2016-05-31 11:32 ` Daniel P. Berrange 2016-06-01 1:31 ` [Qemu-devel] [PATCH 0/2] Let PKGVERSION include the "git describe" output Fam Zheng 0 siblings, 2 replies; 10+ messages in thread From: Laszlo Ersek @ 2016-05-31 11:16 UTC (permalink / raw) To: Peter Maydell, Paolo Bonzini; +Cc: qemu devel list Hi, has this been raised / considered before? To me at least it would be extremely useful if QEMU binaries built from a git working directory returned the output of "git describe" (+ possibly a hint about an unclean working directory), when invoked with "-version". Not volunteering for the implementation, and also not suggesting / requesting that others implement it (everyone is busy with real stuff, I'm sure); just asking if it's been considered. Thanks! Laszlo ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] including the "git describe" output in the QEMU binaries? 2016-05-31 11:16 [Qemu-devel] including the "git describe" output in the QEMU binaries? Laszlo Ersek @ 2016-05-31 11:32 ` Daniel P. Berrange 2016-05-31 12:16 ` Laszlo Ersek 2016-05-31 13:19 ` Daniel P. Berrange 2016-06-01 1:31 ` [Qemu-devel] [PATCH 0/2] Let PKGVERSION include the "git describe" output Fam Zheng 1 sibling, 2 replies; 10+ messages in thread From: Daniel P. Berrange @ 2016-05-31 11:32 UTC (permalink / raw) To: Laszlo Ersek; +Cc: Peter Maydell, Paolo Bonzini, qemu devel list On Tue, May 31, 2016 at 01:16:14PM +0200, Laszlo Ersek wrote: > Hi, > > has this been raised / considered before? To me at least it would be > extremely useful if QEMU binaries built from a git working directory > returned the output of "git describe" (+ possibly a hint about an > unclean working directory), when invoked with "-version". > > Not volunteering for the implementation, and also not suggesting / > requesting that others implement it (everyone is busy with real stuff, > I'm sure); just asking if it's been considered. Currently configure supports a --pkgversion flag which is used by people packaging QEMU in RPM/Debs to include their arbitrary custom version string. This information is then reported by -version and the appropriate QMP command. We could quite easily make configure default the pkgversion to the current GIT hash if --pkgversion is not explicitly given. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] including the "git describe" output in the QEMU binaries? 2016-05-31 11:32 ` Daniel P. Berrange @ 2016-05-31 12:16 ` Laszlo Ersek 2016-05-31 13:19 ` Daniel P. Berrange 1 sibling, 0 replies; 10+ messages in thread From: Laszlo Ersek @ 2016-05-31 12:16 UTC (permalink / raw) To: Daniel P. Berrange; +Cc: Peter Maydell, Paolo Bonzini, qemu devel list On 05/31/16 13:32, Daniel P. Berrange wrote: > On Tue, May 31, 2016 at 01:16:14PM +0200, Laszlo Ersek wrote: >> Hi, >> >> has this been raised / considered before? To me at least it would be >> extremely useful if QEMU binaries built from a git working directory >> returned the output of "git describe" (+ possibly a hint about an >> unclean working directory), when invoked with "-version". >> >> Not volunteering for the implementation, and also not suggesting / >> requesting that others implement it (everyone is busy with real stuff, >> I'm sure); just asking if it's been considered. > > Currently configure supports a --pkgversion flag which is used by people > packaging QEMU in RPM/Debs to include their arbitrary custom version string. > This information is then reported by -version and the appropriate QMP > command. > > We could quite easily make configure default the pkgversion to the current > GIT hash if --pkgversion is not explicitly given. That sounds great, thanks! I'll try to post a patch. I'm thinking of git-describe, plus appending a plus sign (+), when there are uncommitted changes (for which I plan to look with ( ! git diff --quiet || ! git diff --staged --quiet )). Thanks! Laszlo ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] including the "git describe" output in the QEMU binaries? 2016-05-31 11:32 ` Daniel P. Berrange 2016-05-31 12:16 ` Laszlo Ersek @ 2016-05-31 13:19 ` Daniel P. Berrange 2016-05-31 13:26 ` Laszlo Ersek 1 sibling, 1 reply; 10+ messages in thread From: Daniel P. Berrange @ 2016-05-31 13:19 UTC (permalink / raw) To: Laszlo Ersek; +Cc: Peter Maydell, qemu devel list, Paolo Bonzini On Tue, May 31, 2016 at 12:32:48PM +0100, Daniel P. Berrange wrote: > On Tue, May 31, 2016 at 01:16:14PM +0200, Laszlo Ersek wrote: > > Hi, > > > > has this been raised / considered before? To me at least it would be > > extremely useful if QEMU binaries built from a git working directory > > returned the output of "git describe" (+ possibly a hint about an > > unclean working directory), when invoked with "-version". > > > > Not volunteering for the implementation, and also not suggesting / > > requesting that others implement it (everyone is busy with real stuff, > > I'm sure); just asking if it's been considered. > > Currently configure supports a --pkgversion flag which is used by people > packaging QEMU in RPM/Debs to include their arbitrary custom version string. > This information is then reported by -version and the appropriate QMP > command. > > We could quite easily make configure default the pkgversion to the current > GIT hash if --pkgversion is not explicitly given. Oh and the nice thing about this is that it is plumbed into libvirt, so whenever libvirt starts a guest, it will log the pkgversion associated with QEMU to /var/log/libvirt/qemu/$GUEST.log Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] including the "git describe" output in the QEMU binaries? 2016-05-31 13:19 ` Daniel P. Berrange @ 2016-05-31 13:26 ` Laszlo Ersek 0 siblings, 0 replies; 10+ messages in thread From: Laszlo Ersek @ 2016-05-31 13:26 UTC (permalink / raw) To: Daniel P. Berrange; +Cc: Peter Maydell, qemu devel list, Paolo Bonzini On 05/31/16 15:19, Daniel P. Berrange wrote: > On Tue, May 31, 2016 at 12:32:48PM +0100, Daniel P. Berrange wrote: >> On Tue, May 31, 2016 at 01:16:14PM +0200, Laszlo Ersek wrote: >>> Hi, >>> >>> has this been raised / considered before? To me at least it would be >>> extremely useful if QEMU binaries built from a git working directory >>> returned the output of "git describe" (+ possibly a hint about an >>> unclean working directory), when invoked with "-version". >>> >>> Not volunteering for the implementation, and also not suggesting / >>> requesting that others implement it (everyone is busy with real stuff, >>> I'm sure); just asking if it's been considered. >> >> Currently configure supports a --pkgversion flag which is used by people >> packaging QEMU in RPM/Debs to include their arbitrary custom version string. >> This information is then reported by -version and the appropriate QMP >> command. >> >> We could quite easily make configure default the pkgversion to the current >> GIT hash if --pkgversion is not explicitly given. > > Oh and the nice thing about this is that it is plumbed into libvirt, so > whenever libvirt starts a guest, it will log the pkgversion associated > with QEMU to /var/log/libvirt/qemu/$GUEST.log Awesome. I use all my long-term guests (that I keep flipping between upstream and downstream QEMU) with libvirt. Associating log sections with git trees would be great. Let's see if I can write this patch in no more than five iterations... Laszlo ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 0/2] Let PKGVERSION include the "git describe" output 2016-05-31 11:16 [Qemu-devel] including the "git describe" output in the QEMU binaries? Laszlo Ersek 2016-05-31 11:32 ` Daniel P. Berrange @ 2016-06-01 1:31 ` Fam Zheng 2016-06-01 1:31 ` [Qemu-devel] [PATCH 1/2] Makefile: Add a "FORCE" target Fam Zheng 2016-06-01 1:31 ` [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default Fam Zheng 1 sibling, 2 replies; 10+ messages in thread From: Fam Zheng @ 2016-06-01 1:31 UTC (permalink / raw) To: lersek; +Cc: Paolo Bonzini, qemu-devel, qemu-block, berrange, famz Makefile happened to be in my working set because of the docker test work, so I went ahead to try this nice feature last evening before going to bed. My apologies if we have duplicated work. Please review. Fam Zheng (2): Makefile: Add a "FORCE" target Makefile: Derive "PKGVERSION" from "git describe" by default Makefile | 24 ++++++++++++++++++++++-- linux-user/main.c | 1 + qemu-img.c | 1 + qmp.c | 1 + scripts/create_config | 4 ---- vl.c | 1 + 6 files changed, 26 insertions(+), 6 deletions(-) -- 2.8.3 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 1/2] Makefile: Add a "FORCE" target 2016-06-01 1:31 ` [Qemu-devel] [PATCH 0/2] Let PKGVERSION include the "git describe" output Fam Zheng @ 2016-06-01 1:31 ` Fam Zheng 2016-06-01 1:31 ` [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default Fam Zheng 1 sibling, 0 replies; 10+ messages in thread From: Fam Zheng @ 2016-06-01 1:31 UTC (permalink / raw) To: lersek; +Cc: Paolo Bonzini, qemu-devel, qemu-block, berrange, famz Signed-off-by: Fam Zheng <famz@redhat.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a5d7e62..1548b3f 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ Makefile: ; configure: ; .PHONY: all clean cscope distclean dvi html info install install-doc \ - pdf recurse-all speed test dist msi + pdf recurse-all speed test dist msi FORCE $(call set-vpath, $(SRC_PATH)) -- 2.8.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default 2016-06-01 1:31 ` [Qemu-devel] [PATCH 0/2] Let PKGVERSION include the "git describe" output Fam Zheng 2016-06-01 1:31 ` [Qemu-devel] [PATCH 1/2] Makefile: Add a "FORCE" target Fam Zheng @ 2016-06-01 1:31 ` Fam Zheng 2016-06-01 3:05 ` Eric Blake 1 sibling, 1 reply; 10+ messages in thread From: Fam Zheng @ 2016-06-01 1:31 UTC (permalink / raw) To: lersek; +Cc: Paolo Bonzini, qemu-devel, qemu-block, berrange, famz Currently, if not specified in "./configure", QEMU_PKGVERSION will be empty. Write a rule in Makefile to generate a value from "git describe" combined with a possible git tree cleanness suffix, and write into a new header. $ cat qemu-version.h #define QEMU_PKGVERSION "-v2.6.0-557-gd6550e9-unclean" Include the header in .c files where the macro is referenced. It's not necessary to include it in all files, otherwise each time the content of the file changes, all sources have to be recompiled. Signed-off-by: Fam Zheng <famz@redhat.com> --- Makefile | 22 +++++++++++++++++++++- linux-user/main.c | 1 + qemu-img.c | 1 + qmp.c | 1 + scripts/create_config | 4 ---- vl.c | 1 + 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1548b3f..7b4c019 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fa endif endif -GENERATED_HEADERS = config-host.h qemu-options.def +GENERATED_HEADERS = qemu-version.h config-host.h qemu-options.def GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c GENERATED_HEADERS += qmp-introspect.h @@ -169,6 +169,26 @@ endif all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules +qemu-version.h: FORCE + $(call quiet-command, \ + (cd $(SRC_PATH); \ + echo -n '#define QEMU_PKGVERSION '; \ + if test -n "$(PKGVERSION)"; then \ + echo '"$(PKGVERSION)"'; \ + else \ + echo -n '"-'; \ + if ! git status &>/dev/null; then \ + echo -n "no-git"; \ + else \ + git describe 2>/dev/null | tr -d '\n'; \ + if ! git diff-index --quiet HEAD &>/dev/null; then \ + echo -n '-unclean'; \ + fi \ + fi; \ + echo '"'; \ + fi) > $@.tmp) + $(call quiet-command, cmp --quiet $@ $@.tmp || mv $@.tmp $@) + config-host.h: config-host.h-timestamp config-host.h-timestamp: config-host.mak qemu-options.def: $(SRC_PATH)/qemu-options.hx diff --git a/linux-user/main.c b/linux-user/main.c index b2bc6ab..8a11d02 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -17,6 +17,7 @@ * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "qemu-version.h" #include <sys/mman.h> #include <sys/syscall.h> #include <sys/resource.h> diff --git a/qemu-img.c b/qemu-img.c index 4b56ad3..32e307c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu-version.h" #include "qapi/error.h" #include "qapi-visit.h" #include "qapi/qmp-output-visitor.h" diff --git a/qmp.c b/qmp.c index 3165f87..7df6543 100644 --- a/qmp.c +++ b/qmp.c @@ -14,6 +14,7 @@ */ #include "qemu/osdep.h" +#include "qemu-version.h" #include "qemu/cutils.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" diff --git a/scripts/create_config b/scripts/create_config index b2d2ebb..d47057b 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -9,10 +9,6 @@ case $line in version=${line#*=} echo "#define QEMU_VERSION \"$version\"" ;; - PKGVERSION=*) # configuration - pkgversion=${line#*=} - echo "#define QEMU_PKGVERSION \"$pkgversion\"" - ;; qemu_*dir=*) # qemu-specific directory configuration name=${line%=*} value=${line#*=} diff --git a/vl.c b/vl.c index 18d1423..97cad71 100644 --- a/vl.c +++ b/vl.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu-version.h" #include "qemu/cutils.h" #include "qemu/help_option.h" -- 2.8.3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default 2016-06-01 1:31 ` [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default Fam Zheng @ 2016-06-01 3:05 ` Eric Blake 2016-06-01 3:17 ` Fam Zheng 0 siblings, 1 reply; 10+ messages in thread From: Eric Blake @ 2016-06-01 3:05 UTC (permalink / raw) To: Fam Zheng, lersek; +Cc: Paolo Bonzini, qemu-devel, qemu-block [-- Attachment #1: Type: text/plain, Size: 1522 bytes --] On 05/31/2016 07:31 PM, Fam Zheng wrote: > Currently, if not specified in "./configure", QEMU_PKGVERSION will be > empty. Write a rule in Makefile to generate a value from "git describe" > combined with a possible git tree cleanness suffix, and write into a new > header. > > $ cat qemu-version.h > #define QEMU_PKGVERSION "-v2.6.0-557-gd6550e9-unclean" > > Include the header in .c files where the macro is referenced. It's not > necessary to include it in all files, otherwise each time the content of > the file changes, all sources have to be recompiled. > > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > +qemu-version.h: FORCE > + $(call quiet-command, \ > + (cd $(SRC_PATH); \ Can CDPATH interfere with this one? > + echo -n '#define QEMU_PKGVERSION '; \ 'echo -n' is non-portable, use printf instead. > + if test -n "$(PKGVERSION)"; then \ > + echo '"$(PKGVERSION)"'; \ > + else \ > + echo -n '"-'; \ And again > + if ! git status &>/dev/null; then \ > + echo -n "no-git"; \ and again > + else \ > + git describe 2>/dev/null | tr -d '\n'; \ > + if ! git diff-index --quiet HEAD &>/dev/null; then \ > + echo -n '-unclean'; \ and again Why -unclean instead of -dirty? > + fi \ > + fi; \ > + echo '"'; \ > + fi) > $@.tmp) > + $(call quiet-command, cmp --quiet $@ $@.tmp || mv $@.tmp $@) > + -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default 2016-06-01 3:05 ` Eric Blake @ 2016-06-01 3:17 ` Fam Zheng 0 siblings, 0 replies; 10+ messages in thread From: Fam Zheng @ 2016-06-01 3:17 UTC (permalink / raw) To: Eric Blake; +Cc: lersek, Paolo Bonzini, qemu-devel, qemu-block On Tue, 05/31 21:05, Eric Blake wrote: > On 05/31/2016 07:31 PM, Fam Zheng wrote: > > Currently, if not specified in "./configure", QEMU_PKGVERSION will be > > empty. Write a rule in Makefile to generate a value from "git describe" > > combined with a possible git tree cleanness suffix, and write into a new > > header. > > > > $ cat qemu-version.h > > #define QEMU_PKGVERSION "-v2.6.0-557-gd6550e9-unclean" > > > > Include the header in .c files where the macro is referenced. It's not > > necessary to include it in all files, otherwise each time the content of > > the file changes, all sources have to be recompiled. > > > > Signed-off-by: Fam Zheng <famz@redhat.com> > > --- > > > +qemu-version.h: FORCE > > + $(call quiet-command, \ > > + (cd $(SRC_PATH); \ > > Can CDPATH interfere with this one? I think SRC_PATH is either an absolute path, or is ".". Both cases are fine. > > > + echo -n '#define QEMU_PKGVERSION '; \ > > 'echo -n' is non-portable, use printf instead. Will fix. > > > + if test -n "$(PKGVERSION)"; then \ > > + echo '"$(PKGVERSION)"'; \ > > + else \ > > + echo -n '"-'; \ > > And again > > > + if ! git status &>/dev/null; then \ > > + echo -n "no-git"; \ > > and again > > > + else \ > > + git describe 2>/dev/null | tr -d '\n'; \ > > + if ! git diff-index --quiet HEAD &>/dev/null; then \ > > + echo -n '-unclean'; \ > > and again > > Why -unclean instead of -dirty? The non-native speaker can fix that. > > > + fi \ > > + fi; \ > > + echo '"'; \ > > + fi) > $@.tmp) > > + $(call quiet-command, cmp --quiet $@ $@.tmp || mv $@.tmp $@) > > + > > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > Thanks, Fam ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-06-01 3:17 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-31 11:16 [Qemu-devel] including the "git describe" output in the QEMU binaries? Laszlo Ersek 2016-05-31 11:32 ` Daniel P. Berrange 2016-05-31 12:16 ` Laszlo Ersek 2016-05-31 13:19 ` Daniel P. Berrange 2016-05-31 13:26 ` Laszlo Ersek 2016-06-01 1:31 ` [Qemu-devel] [PATCH 0/2] Let PKGVERSION include the "git describe" output Fam Zheng 2016-06-01 1:31 ` [Qemu-devel] [PATCH 1/2] Makefile: Add a "FORCE" target Fam Zheng 2016-06-01 1:31 ` [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default Fam Zheng 2016-06-01 3:05 ` Eric Blake 2016-06-01 3:17 ` Fam Zheng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).