From: Pekka Enberg Subject: [PATCH] kvm tool: Fix builtin command usage printouts Date: Wed, 10 Aug 2011 21:35:13 +0300 Message-ID: <1313001313-4586-1-git-send-email-penberg@kernel.org> Cc: Pekka Enberg , Asias He , Cyrill Gorcunov , Ingo Molnar , Prasad Joshi , Sasha Levin To: kvm@vger.kernel.org Return-path: Received: from filtteri5.pp.htv.fi ([213.243.153.188]:41104 "EHLO filtteri5.pp.htv.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754575Ab1HJSfQ (ORCPT ); Wed, 10 Aug 2011 14:35:16 -0400 Sender: kvm-owner@vger.kernel.org List-ID: 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 Cc: Cyrill Gorcunov Cc: Ingo Molnar Cc: Prasad Joshi Cc: Sasha Levin Signed-off-by: Pekka Enberg --- 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 #include #include +#include #include +static const char * const balloon_usage[] = { + "kvm balloon {inflate|deflate} ", + 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 #include #include +#include #include #include #include +static const char * const debug_usage[] = { + "kvm debug ", + 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 #include #include +#include + +static const char * const pause_usage[] = { + "kvm pause ", + 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 #include #include +#include + +static const char * const resume_usage[] = { + "kvm resume ", + 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 #include #include +#include #include #include #include +static const char * const stop_usage[] = { + "kvm stop ", + 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