]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core/driver: Add version information
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 27 Aug 2014 22:25:36 +0000 (00:25 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 18:08:56 +0000 (20:08 +0200)
Create a version string in the format

    vX.Y (<commits-since-vX.Y>-<git-hash>[-dirty])

and embed it into the hypervisor core as well as the driver module.
Helps to identify what is actually executed.

The management tool is more decoupled from those two and will get a
simpler version tag.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
.gitignore
Makefile
VERSION [new file with mode: 0644]
driver.c
hypervisor/Makefile
hypervisor/setup.c
scripts/gen_version_h [new file with mode: 0755]

index 5be98d5a937ec7e1f74988e8258ab89c30e420e9..26efab4c6190845ad12db53f987af1c19ca3f797 100644 (file)
@@ -8,7 +8,9 @@
 Module.symvers
 modules.order
 jailhouse.ko
+jailhouse-version.h
 hypervisor/include/jailhouse/config.h
+hypervisor/include/jailhouse/version.h
 hypervisor/hypervisor.lds
 tools/jailhouse
 tools/jailhouse-config-collect
index 67dc1a0785ef0234c77a03fb1ed96ed5cea04d51..629fabe73b1eaaad9eedf142e1e0e6e9ff68c9a9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,12 @@ ccflags-y := -I$(src)/hypervisor/arch/$(SRCARCH)/include \
 
 jailhouse-y := driver.o
 
+define filechk_version
+       $(src)/scripts/gen_version_h $(src)
+endef
+
+clean-files := jailhouse-version.h
+
 # out-of-tree build
 
 KERNELDIR = /lib/modules/`uname -r`/build
@@ -26,6 +32,11 @@ KERNELDIR = /lib/modules/`uname -r`/build
 modules modules_install clean:
        $(MAKE) -C $(KERNELDIR) SUBDIRS=`pwd` $@
 
+$(obj)/jailhouse-version.h: $(src)/Makefile FORCE
+       $(call filechk,version)
+
+$(obj)/driver.o: $(obj)/jailhouse-version.h
+
 firmware_install:
        cp hypervisor/jailhouse.bin /lib/firmware/
 
diff --git a/VERSION b/VERSION
new file mode 100644 (file)
index 0000000..ba9d51a
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+<no-version>
index a7e91dea188d0eed4befc3577100ef1be2260af1..21a04a39a3719b4fe1a8d2675308366f58c4443d 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -1,7 +1,7 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2013
+ * Copyright (c) Siemens AG, 2013, 2014
  *
  * Authors:
  *  Jan Kiszka <jan.kiszka@siemens.com>
@@ -28,6 +28,7 @@
 #include <asm/cacheflush.h>
 
 #include "jailhouse.h"
+#include "jailhouse-version.h"
 #include <jailhouse/cell-config.h>
 #include <jailhouse/header.h>
 #include <jailhouse/hypercall.h>
@@ -95,6 +96,7 @@ struct cell {
 MODULE_DESCRIPTION("Loader for Jailhouse partitioning hypervisor");
 MODULE_LICENSE("GPL");
 MODULE_FIRMWARE(JAILHOUSE_FW_NAME);
+MODULE_VERSION(JAILHOUSE_VERSION);
 
 static struct device *jailhouse_dev;
 static DEFINE_MUTEX(lock);
index 827209f90cee347bfb77fbcd6646ce4fa791dea1..ae499ecf29dd85577cc2b4fa7318262c12879696 100644 (file)
@@ -34,6 +34,17 @@ hypervisor-y := setup.o printk.o paging.o control.o lib.o \
        arch/$(SRCARCH)/built-in.o hypervisor.lds
 targets += $(hypervisor-y)
 
+define filechk_version
+       $(src)/../scripts/gen_version_h $(src)/..
+endef
+
+clean-files := $(obj)/include/jailhouse/version.h
+
+$(obj)/include/jailhouse/version.h: $(src)/Makefile FORCE
+       $(call filechk,version)
+
+$(obj)/setup.o: $(obj)/include/jailhouse/version.h
+
 HYPERVISOR_OBJS = $(addprefix $(obj)/,$(hypervisor-y))
 
 LDFLAGS_hypervisor.o := -T
index 2f059c8a2f74bca522a97cd317525ed022aca739..8facad1d7ead2a694d27d35429f58945c1487e86 100644 (file)
@@ -16,6 +16,7 @@
 #include <jailhouse/paging.h>
 #include <jailhouse/control.h>
 #include <jailhouse/string.h>
+#include <jailhouse/version.h>
 #include <asm/spinlock.h>
 
 extern u8 __text_start[], __hv_core_end[];
@@ -38,7 +39,8 @@ static void init_early(unsigned int cpu_id)
 
        arch_dbg_write_init();
 
-       printk("\nInitializing Jailhouse hypervisor on CPU %d\n", cpu_id);
+       printk("\nInitializing Jailhouse hypervisor %s on CPU %d\n",
+              JAILHOUSE_VERSION, cpu_id);
        printk("Code location: %p\n", __text_start);
 
        error = paging_init();
diff --git a/scripts/gen_version_h b/scripts/gen_version_h
new file mode 100755 (executable)
index 0000000..91d278f
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# Jailhouse, a Linux-based partitioning hypervisor
+#
+# Copyright (c) Siemens AG, 2014
+#
+# Authors:
+#  Jan Kiszka <jan.kiszka@siemens.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+echo -e "/* Auto-generated - leave alone and don't commit! */\n"
+
+if ! git rev-parse 2>/dev/null; then
+       version="`cat $1/VERSION`"
+else
+       cd $1 > /dev/null
+       git diff > diff.log
+       describe="`git describe --long --dirty --match "v[0-9].[0-9]*"`"
+       version="`echo $describe | sed -e 's/\([^-]*\)-\(.*\)/\1 (\2)/'`"
+       cd - > /dev/null
+fi
+
+echo "#define JAILHOUSE_VERSION        \"$version\""