From f75ae77b0f0555c1e446df098547af0dc297dda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Meireles?= Date: Mon, 22 Jun 2015 16:44:16 +0100 Subject: [PATCH] add -v flag in order to easily spot running version. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: António Meireles --- Makefile | 4 ++++ src/xhyve.c | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 587b409..d565215 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags) + ifeq ($V, 1) VERBOSE = else @@ -72,6 +74,8 @@ OBJ := $(SRC:src/%.c=build/%.o) DEP := $(OBJ:%.o=%.d) INC := -Iinclude +CFLAGS += -DVERSION=\"$(GIT_VERSION)\" + TARGET = build/xhyve all: $(TARGET) | build diff --git a/src/xhyve.c b/src/xhyve.c index 0348219..068381c 100644 --- a/src/xhyve.c +++ b/src/xhyve.c @@ -112,7 +112,7 @@ static struct bhyvestats { #pragma clang diagnostic ignored "-Wpadded" static struct mt_vmm_info { pthread_t mt_thr; - int mt_vcpu; + int mt_vcpu; } mt_vmm_info[VM_MAXCPU]; #pragma clang diagnostic pop @@ -138,6 +138,7 @@ usage(int code) " -s: PCI slot config\n" " -u: RTC keeps UTC time\n" " -U: uuid\n" + " -v: show build version\n" " -w: ignore unimplemented MSRs\n" " -W: force virtio to use single-vector MSI\n" " -x: local apic is in x2APIC mode\n" @@ -147,6 +148,17 @@ usage(int code) exit(code); } +__attribute__ ((noreturn)) static void +show_version() +{ + fprintf(stderr, "%s: %s\n\n%s\n",progname, VERSION, + "xhyve is a port of FreeBSD's bhyve hypervisor to OS X that\n" + "works entirely in userspace and has no other dependencies.\n\n" + "Homepage: https://github.com/mist64/xhyve\n" + "License: BSD\n"); + exit(0); +} + void xh_vm_inject_fault(int vcpu, int vector, int errcode_valid, uint32_t errcode) @@ -765,7 +777,7 @@ main(int argc, char *argv[]) rtc_localtime = 1; fw = 0; - while ((c = getopt(argc, argv, "behuwxACHPWY:f:g:c:s:m:l:U:")) != -1) { + while ((c = getopt(argc, argv, "behvuwxACHPWY:f:g:c:s:m:l:U:")) != -1) { switch (c) { case 'A': acpi = 1; @@ -832,8 +844,10 @@ main(int argc, char *argv[]) case 'Y': mptgen = 0; break; + case 'v': + show_version(); case 'h': - usage(0); + usage(0); default: usage(1); }