kvm tool: Fix builtin command usage printouts
PATCH 1/1 kvm tool: Fix builtin command usage printouts
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 <[email protected]>
Cc Cyrill Gorcunov <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Prasad Joshi <[email protected]>
Cc Sasha Levin <[email protected]>
Signed-off-by Pekka Enberg <[email protected]>
--- 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(-)
tools/kvm/builtin-balloon.c +11 -1
@@ -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 )
tools/kvm/builtin-debug.c +11 -1
@@ -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);
tools/kvm/builtin-pause.c +11 -1
@@ -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);
tools/kvm/builtin-resume.c +11 -1
@@ -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);
tools/kvm/builtin-stop.c +11 -1
@@ -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);
Signature · 1 line
1.7.0.4