From patchwork Wed Aug 10 18:35:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pekka Enberg X-Patchwork-Id: 1054612 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7AIqRU9017042 for ; Wed, 10 Aug 2011 18:52:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754586Ab1HJSfQ (ORCPT ); Wed, 10 Aug 2011 14:35:16 -0400 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 Received: from localhost (localhost [127.0.0.1]) by filtteri5.pp.htv.fi (Postfix) with ESMTP id A5FF05A635A; Wed, 10 Aug 2011 21:35:14 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp4.welho.com ([213.243.153.38]) by localhost (filtteri5.pp.htv.fi [213.243.153.188]) (amavisd-new, port 10024) with ESMTP id eAiP09wFFNk9; Wed, 10 Aug 2011 21:35:14 +0300 (EEST) Received: from localhost.localdomain (cs181136138.pp.htv.fi [82.181.136.138]) by smtp4.welho.com (Postfix) with ESMTP id 35DAC5BC010; Wed, 10 Aug 2011 21:35:14 +0300 (EEST) From: Pekka Enberg To: kvm@vger.kernel.org Cc: Pekka Enberg , Asias He , Cyrill Gorcunov , Ingo Molnar , Prasad Joshi , Sasha Levin 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> X-Mailer: git-send-email 1.7.0.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 10 Aug 2011 18:52:29 +0000 (UTC) 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);