[tip:tools/kvm] kvm tools: Add 'kvm version' command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  ed28f143a3a84c682d5de148db2b8173166dee0d
Gitweb:     http://git.kernel.org/tip/ed28f143a3a84c682d5de148db2b8173166dee0d
Author:     Sasha Levin <levinsasha928@xxxxxxxxx>
AuthorDate: Sat, 9 Jul 2011 00:56:08 +0300
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Sat, 9 Jul 2011 01:23:03 +0300

kvm tools: Add 'kvm version' command

Add a 'kvm version' command which prints the version of the kernel
used to build kvm tools.

Part of the code is based on and was loaned from perf.

Suggested-by: Ingo Molnar <mingo@xxxxxxx>
Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/Documentation/kvm-version.txt            |   21 ++++++++++++++++++++
 tools/kvm/Makefile                                 |    7 ++++++
 tools/kvm/command-list.txt                         |    1 +
 tools/kvm/include/kvm/kvm-version.h                |    6 +++++
 tools/kvm/kvm-cmd.c                                |    2 +
 tools/kvm/kvm-version.c                            |   15 ++++++++++++++
 .../util/KVMTOOLS-VERSION-GEN}                     |   10 +++-----
 7 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/tools/kvm/Documentation/kvm-version.txt b/tools/kvm/Documentation/kvm-version.txt
new file mode 100644
index 0000000..bf51540
--- /dev/null
+++ b/tools/kvm/Documentation/kvm-version.txt
@@ -0,0 +1,21 @@
+kvm-version(1)
+================
+
+NAME
+----
+kvm-version - Print the version of the kernel tree kvm tools
+was built on.
+
+SYNOPSIS
+--------
+[verse]
+'kvm version'
+
+DESCRIPTION
+-----------
+The command prints the version of the kernel that was used to build
+kvm tools.
+
+Note that the version is not the version of the kernel which is currently
+running on the host, but is the version of the kernel tree from which kvm
+tools was built.
diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile
index 51a3d1a..5ec222f 100644
--- a/tools/kvm/Makefile
+++ b/tools/kvm/Makefile
@@ -61,6 +61,7 @@ OBJS	+= kvm-pause.o
 OBJS	+= kvm-balloon.o
 OBJS	+= kvm-list.o
 OBJS	+= kvm-run.o
+OBJS	+= kvm-version.o
 OBJS	+= mptable.o
 OBJS	+= rbtree.o
 OBJS	+= threadpool.o
@@ -124,6 +125,7 @@ endif
 
 DEFINES	+= -D_FILE_OFFSET_BITS=64
 DEFINES	+= -D_GNU_SOURCE
+DEFINES	+= -DKVMTOOLS_VERSION='"$(KVMTOOLS_VERSION)"'
 
 KVM_INCLUDE := include
 CFLAGS	+= $(CPPFLAGS) $(DEFINES) -I$(KVM_INCLUDE) -I../../include -I../../arch/$(ARCH)/include/ -Os -g
@@ -152,6 +154,10 @@ CFLAGS	+= $(WARNINGS)
 
 all: $(PROGRAM)
 
+KVMTOOLS-VERSION-FILE:
+	@$(SHELL_PATH) util/KVMTOOLS-VERSION-GEN $(OUTPUT)
+-include $(OUTPUT)KVMTOOLS-VERSION-FILE
+
 $(PROGRAM): $(DEPS) $(OBJS)
 	$(E) "  LINK    " $@
 	$(Q) $(CC) $(OBJS) $(LIBS) -o $@
@@ -168,6 +174,7 @@ $(OBJS):
 
 rbtree.o: ../../lib/rbtree.c
 	$(Q) $(CC) -c $(CFLAGS) $< -o $@
+
 %.o: %.c
 	$(E) "  CC      " $@
 	$(Q) $(CC) -c $(CFLAGS) $< -o $@
diff --git a/tools/kvm/command-list.txt b/tools/kvm/command-list.txt
index 36dcd67b..81ba140 100644
--- a/tools/kvm/command-list.txt
+++ b/tools/kvm/command-list.txt
@@ -4,3 +4,4 @@
 #
 kvm-run				mainporcelain common
 kvm-pause			common
+kvm-version			common
diff --git a/tools/kvm/include/kvm/kvm-version.h b/tools/kvm/include/kvm/kvm-version.h
new file mode 100644
index 0000000..83cac4d
--- /dev/null
+++ b/tools/kvm/include/kvm/kvm-version.h
@@ -0,0 +1,6 @@
+#ifndef KVM__VERSION_H
+#define KVM__VERSION_H
+
+int kvm_cmd_version(int argc, const char **argv, const char *prefix);
+
+#endif
diff --git a/tools/kvm/kvm-cmd.c b/tools/kvm/kvm-cmd.c
index cecf0d0..404065b 100644
--- a/tools/kvm/kvm-cmd.c
+++ b/tools/kvm/kvm-cmd.c
@@ -9,6 +9,7 @@
 #include "kvm/kvm-pause.h"
 #include "kvm/kvm-balloon.h"
 #include "kvm/kvm-list.h"
+#include "kvm/kvm-version.h"
 #include "kvm/kvm-help.h"
 #include "kvm/kvm-cmd.h"
 #include "kvm/kvm-run.h"
@@ -18,6 +19,7 @@ struct cmd_struct kvm_commands[] = {
 	{ "debug",	kvm_cmd_debug,		NULL,         0 },
 	{ "balloon",	kvm_cmd_balloon,	NULL,         0 },
 	{ "list",	kvm_cmd_list,		NULL,         0 },
+	{ "version",	kvm_cmd_version,	NULL,         0 },
 	{ "help",	kvm_cmd_help,		NULL,         0 },
 	{ "run",	kvm_cmd_run,		kvm_run_help, 0 },
 	{ NULL,		NULL,			NULL,         0 },
diff --git a/tools/kvm/kvm-version.c b/tools/kvm/kvm-version.c
new file mode 100644
index 0000000..e30f74c
--- /dev/null
+++ b/tools/kvm/kvm-version.c
@@ -0,0 +1,15 @@
+#include <kvm/util.h>
+#include <kvm/kvm-cmd.h>
+#include <kvm/kvm-version.h>
+#include <kvm/kvm.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+int kvm_cmd_version(int argc, const char **argv, const char *prefix)
+{
+	printf("%s\n", KVMTOOLS_VERSION);
+
+	return 0;
+}
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/kvm/util/KVMTOOLS-VERSION-GEN
similarity index 80%
copy from tools/perf/util/PERF-VERSION-GEN
copy to tools/kvm/util/KVMTOOLS-VERSION-GEN
index ad73300..1af9d6c 100755
--- a/tools/perf/util/PERF-VERSION-GEN
+++ b/tools/kvm/util/KVMTOOLS-VERSION-GEN
@@ -4,7 +4,7 @@ if [ $# -eq 1 ]  ; then
 	OUTPUT=$1
 fi
 
-GVF=${OUTPUT}PERF-VERSION-FILE
+GVF=${OUTPUT}KVMTOOLS-VERSION-FILE
 
 LF='
 '
@@ -30,13 +30,11 @@ VN=$(expr "$VN" : v*'\(.*\)')
 
 if test -r $GVF
 then
-	VC=$(sed -e 's/^PERF_VERSION = //' <$GVF)
+	VC=$(sed -e 's/^KVMTOOLS_VERSION = //' <$GVF)
 else
 	VC=unset
 fi
 test "$VN" = "$VC" || {
-	echo >&2 "PERF_VERSION = $VN"
-	echo "PERF_VERSION = $VN" >$GVF
+	echo >&2 "KVMTOOLS_VERSION = $VN"
+	echo "KVMTOOLS_VERSION = $VN" >$GVF
 }
-
-
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux