[PATCH] kvm tool: Fix builtin command usage printouts

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

 



This patch fixes builtin commands to use usage_with_options() instead of die().
The latter prefixes messages with "Fatal" which makes the usage text ugly.

Cc: Asias He <asias.hejun@xxxxxxxxx>
Cc: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Prasad Joshi <prasadjoshi124@xxxxxxxxx>
Cc: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-balloon.c |   12 +++++++++++-
 tools/kvm/builtin-debug.c   |   12 +++++++++++-
 tools/kvm/builtin-pause.c   |   12 +++++++++++-
 tools/kvm/builtin-resume.c  |   12 +++++++++++-
 tools/kvm/builtin-stop.c    |   12 +++++++++++-
 5 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/tools/kvm/builtin-balloon.c b/tools/kvm/builtin-balloon.c
index ce076ba..907a56a 100644
--- a/tools/kvm/builtin-balloon.c
+++ b/tools/kvm/builtin-balloon.c
@@ -5,8 +5,18 @@
 #include <kvm/util.h>
 #include <kvm/kvm-cmd.h>
 #include <kvm/builtin-balloon.h>
+#include <kvm/parse-options.h>
 #include <kvm/kvm.h>
 
+static const char * const balloon_usage[] = {
+	"kvm balloon {inflate|deflate} <size in MiB> <instance name>",
+	NULL
+};
+
+static const struct option balloon_options[] = {
+	OPT_END()
+};
+
 int kvm_cmd_balloon(int argc, const char **argv, const char *prefix)
 {
 	int pid;
@@ -14,7 +24,7 @@ int kvm_cmd_balloon(int argc, const char **argv, const char *prefix)
 	int inflate = 0;
 
 	if (argc != 3)
-		die("Usage: kvm balloon [inflate/deflate] [size in MiB] [instance name]\n");
+		usage_with_options(balloon_usage, balloon_options);
 
 	pid = kvm__get_pid_by_instance(argv[2]);
 	if (pid < 0)
diff --git a/tools/kvm/builtin-debug.c b/tools/kvm/builtin-debug.c
index 4cf3b7c..adb0b54 100644
--- a/tools/kvm/builtin-debug.c
+++ b/tools/kvm/builtin-debug.c
@@ -2,11 +2,21 @@
 #include <kvm/kvm-cmd.h>
 #include <kvm/builtin-debug.h>
 #include <kvm/kvm.h>
+#include <kvm/parse-options.h>
 
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
 
+static const char * const debug_usage[] = {
+	"kvm debug <instance name>",
+	NULL
+};
+
+static const struct option debug_options[] = {
+	OPT_END()
+};
+
 static int do_debug(const char *name, int pid)
 {
 	return kill(pid, SIGQUIT);
@@ -17,7 +27,7 @@ int kvm_cmd_debug(int argc, const char **argv, const char *prefix)
 	int pid;
 
 	if (argc != 1)
-		die("Usage: kvm debug [instance name]\n");
+		usage_with_options(debug_usage, debug_options);
 
 	if (strcmp(argv[0], "all") == 0) {
 		return kvm__enumerate_instances(do_debug);
diff --git a/tools/kvm/builtin-pause.c b/tools/kvm/builtin-pause.c
index f5805e6..7ac793c 100644
--- a/tools/kvm/builtin-pause.c
+++ b/tools/kvm/builtin-pause.c
@@ -6,6 +6,16 @@
 #include <kvm/kvm-cmd.h>
 #include <kvm/builtin-pause.h>
 #include <kvm/kvm.h>
+#include <kvm/parse-options.h>
+
+static const char * const pause_usage[] = {
+	"kvm pause <instance name>",
+	NULL
+};
+
+static const struct option pause_options[] = {
+	OPT_END()
+};
 
 static int do_pause(const char *name, int pid)
 {
@@ -17,7 +27,7 @@ int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
 	int pid;
 
 	if (argc != 1)
-		die("Usage: kvm pause [instance name]\n");
+		usage_with_options(pause_usage, pause_options);
 
 	if (strcmp(argv[0], "all") == 0) {
 		return kvm__enumerate_instances(do_pause);
diff --git a/tools/kvm/builtin-resume.c b/tools/kvm/builtin-resume.c
index a9bf6c5..3b08d3f 100644
--- a/tools/kvm/builtin-resume.c
+++ b/tools/kvm/builtin-resume.c
@@ -6,6 +6,16 @@
 #include <kvm/kvm-cmd.h>
 #include <kvm/builtin-resume.h>
 #include <kvm/kvm.h>
+#include <kvm/parse-options.h>
+
+static const char * const resume_usage[] = {
+	"kvm resume <instance name>",
+	NULL
+};
+
+static const struct option resume_options[] = {
+	OPT_END()
+};
 
 static int do_resume(const char *name, int pid)
 {
@@ -17,7 +27,7 @@ int kvm_cmd_resume(int argc, const char **argv, const char *prefix)
 	int pid;
 
 	if (argc != 1)
-		die("Usage: kvm resume [instance name]\n");
+		usage_with_options(resume_usage, resume_options);
 
 	if (strcmp(argv[0], "all") == 0) {
 		return kvm__enumerate_instances(do_resume);
diff --git a/tools/kvm/builtin-stop.c b/tools/kvm/builtin-stop.c
index 46be393..efbf979 100644
--- a/tools/kvm/builtin-stop.c
+++ b/tools/kvm/builtin-stop.c
@@ -2,11 +2,21 @@
 #include <kvm/kvm-cmd.h>
 #include <kvm/builtin-stop.h>
 #include <kvm/kvm.h>
+#include <kvm/parse-options.h>
 
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
 
+static const char * const stop_usage[] = {
+	"kvm stop <instance name>",
+	NULL
+};
+
+static const struct option stop_options[] = {
+	OPT_END()
+};
+
 static int do_stop(const char *name, int pid)
 {
 	return kill(pid, SIGKVMSTOP);
@@ -17,7 +27,7 @@ int kvm_cmd_stop(int argc, const char **argv, const char *prefix)
 	int pid;
 
 	if (argc != 1)
-		die("Usage: kvm stop [instance name]\n");
+		usage_with_options(stop_usage, stop_options);
 
 	if (strcmp(argv[0], "all") == 0) {
 		return kvm__enumerate_instances(do_stop);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux