]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Connect existing command helpers to 'kvm help'
authorSasha Levin <levinsasha928@gmail.com>
Fri, 12 Aug 2011 15:20:55 +0000 (18:20 +0300)
committerPekka Enberg <penberg@kernel.org>
Fri, 12 Aug 2011 15:26:33 +0000 (18:26 +0300)
This patch connects usage helpers to 'kvm help' callbacks, allowing
to see help about a command by doing 'kvm help [command]'.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 files changed:
tools/kvm/builtin-balloon.c
tools/kvm/builtin-debug.c
tools/kvm/builtin-list.c
tools/kvm/builtin-pause.c
tools/kvm/builtin-resume.c
tools/kvm/builtin-stop.c
tools/kvm/include/kvm/builtin-balloon.h
tools/kvm/include/kvm/builtin-debug.h
tools/kvm/include/kvm/builtin-list.h
tools/kvm/include/kvm/builtin-pause.h
tools/kvm/include/kvm/builtin-resume.h
tools/kvm/include/kvm/builtin-stop.h
tools/kvm/kvm-cmd.c

index 907a56a735e92501afff645e388800a2dee069d3..08795cd599589d6e4a3d342eafb1f48dd342b583 100644 (file)
@@ -17,6 +17,11 @@ static const struct option balloon_options[] = {
        OPT_END()
 };
 
+void kvm_balloon_help(void)
+{
+       usage_with_options(balloon_usage, balloon_options);
+}
+
 int kvm_cmd_balloon(int argc, const char **argv, const char *prefix)
 {
        int pid;
@@ -24,7 +29,7 @@ int kvm_cmd_balloon(int argc, const char **argv, const char *prefix)
        int inflate = 0;
 
        if (argc != 3)
-               usage_with_options(balloon_usage, balloon_options);
+               kvm_balloon_help();
 
        pid = kvm__get_pid_by_instance(argv[2]);
        if (pid < 0)
index adb0b54724061d68accf2c13f8bedeb9cdbf2061..444ec518fc134487ecca83289e045a6c6dee7ba3 100644 (file)
@@ -17,6 +17,11 @@ static const struct option debug_options[] = {
        OPT_END()
 };
 
+void kvm_debug_help(void)
+{
+       usage_with_options(debug_usage, debug_options);
+}
+
 static int do_debug(const char *name, int pid)
 {
        return kill(pid, SIGQUIT);
@@ -27,7 +32,7 @@ int kvm_cmd_debug(int argc, const char **argv, const char *prefix)
        int pid;
 
        if (argc != 1)
-               usage_with_options(debug_usage, debug_options);
+               kvm_debug_help();
 
        if (strcmp(argv[0], "all") == 0) {
                return kvm__enumerate_instances(do_debug);
index 34cc03bc95d161b100633cf7b199f34a44b93f7a..fcf9bb0ec29d2b3dee311e644cdd3feec8ba8360 100644 (file)
@@ -2,6 +2,7 @@
 #include <kvm/kvm-cmd.h>
 #include <kvm/builtin-list.h>
 #include <kvm/kvm.h>
+#include <kvm/parse-options.h>
 
 #include <stdio.h>
 #include <string.h>
 
 #define PROCESS_NAME "kvm"
 
+static const char * const list_usage[] = {
+       "kvm list",
+       NULL
+};
+
+static const struct option list_options[] = {
+       OPT_END()
+};
+
+void kvm_list_help(void)
+{
+       usage_with_options(list_usage, list_options);
+}
+
 static int print_guest(const char *name, int pid)
 {
        char proc_name[PATH_MAX];
index 7ac793c56b3ef0c0249c0e3f7a15404f8b6b14f8..7a6a6c72e0c9a175277bca880ceb70c21bb1e33a 100644 (file)
@@ -17,6 +17,11 @@ static const struct option pause_options[] = {
        OPT_END()
 };
 
+void kvm_pause_help(void)
+{
+       usage_with_options(pause_usage, pause_options);
+}
+
 static int do_pause(const char *name, int pid)
 {
        return kill(pid, SIGUSR2);
@@ -27,7 +32,7 @@ int kvm_cmd_pause(int argc, const char **argv, const char *prefix)
        int pid;
 
        if (argc != 1)
-               usage_with_options(pause_usage, pause_options);
+               kvm_pause_help();
 
        if (strcmp(argv[0], "all") == 0) {
                return kvm__enumerate_instances(do_pause);
index 3b08d3fa8f277f64ccc20c0f9fdb622689c3c708..b004f2dffdcd961b89146b586d017126a2a50f8e 100644 (file)
@@ -17,6 +17,11 @@ static const struct option resume_options[] = {
        OPT_END()
 };
 
+void kvm_resume_help(void)
+{
+       usage_with_options(resume_usage, resume_options);
+}
+
 static int do_resume(const char *name, int pid)
 {
        return kill(pid, SIGKVMRESUME);
@@ -27,7 +32,7 @@ int kvm_cmd_resume(int argc, const char **argv, const char *prefix)
        int pid;
 
        if (argc != 1)
-               usage_with_options(resume_usage, resume_options);
+               kvm_resume_help();
 
        if (strcmp(argv[0], "all") == 0) {
                return kvm__enumerate_instances(do_resume);
index efbf979cdf08a4aaff214dcd785ad25e49dcebd8..de3113295d7a69b9c41cec429f764dcbed4a2190 100644 (file)
@@ -17,6 +17,11 @@ static const struct option stop_options[] = {
        OPT_END()
 };
 
+void kvm_stop_help(void)
+{
+       usage_with_options(stop_usage, stop_options);
+}
+
 static int do_stop(const char *name, int pid)
 {
        return kill(pid, SIGKVMSTOP);
@@ -27,7 +32,7 @@ int kvm_cmd_stop(int argc, const char **argv, const char *prefix)
        int pid;
 
        if (argc != 1)
-               usage_with_options(stop_usage, stop_options);
+               kvm_stop_help();
 
        if (strcmp(argv[0], "all") == 0) {
                return kvm__enumerate_instances(do_stop);
index f5f92b9e37d23581b066f50c57003215368722c7..85055ebf715dfdddb30bc4d73a6a35b1c94915c8 100644 (file)
@@ -2,5 +2,6 @@
 #define KVM__BALLOON_H
 
 int kvm_cmd_balloon(int argc, const char **argv, const char *prefix);
+void kvm_balloon_help(void);
 
 #endif
index 190cf3189fd79fae2b17b17d62d67f736db8553b..3fc2469fd62b77523caf3109ea3505da3f5a4514 100644 (file)
@@ -2,5 +2,6 @@
 #define KVM__DEBUG_H
 
 int kvm_cmd_debug(int argc, const char **argv, const char *prefix);
+void kvm_debug_help(void);
 
 #endif
index eba9cfdee614b78d207c8c5014f64a7dcc8263e8..04fca22eeab0dbaef215226440f669bedacd1301 100644 (file)
@@ -2,5 +2,6 @@
 #define KVM__LIST_H
 
 int kvm_cmd_list(int argc, const char **argv, const char *prefix);
+void kvm_list_help(void);
 
 #endif
index 0f8e96b9e115df924f100623ff8d2aafc55ebb74..540cc8e7bf623c34d02606af1d1bd7ef804669b8 100644 (file)
@@ -2,5 +2,6 @@
 #define KVM__PAUSE_H
 
 int kvm_cmd_pause(int argc, const char **argv, const char *prefix);
+void kvm_pause_help(void);
 
 #endif
index 4a6474752ea30e9ef2c4186a177ddcfcad6c4904..9e6e8d7837cee09f96149a03ee75e341679a3bbe 100644 (file)
@@ -2,5 +2,6 @@
 #define KVM__RESUME_H
 
 int kvm_cmd_resume(int argc, const char **argv, const char *prefix);
+void kvm_resume_help(void);
 
 #endif
index 317d34dc8f9988e5ea7531809efaf66e69b8e85d..75706953586013a36912f8707b3a11dd670ebcff 100644 (file)
@@ -2,5 +2,6 @@
 #define KVM__STOP_H
 
 int kvm_cmd_stop(int argc, const char **argv, const char *prefix);
+void kvm_stop_help(void);
 
 #endif
index 3a90d6d6d45378a8710e19a88fa0397e2505adcf..4e3ea22491f00ac2f24e7990820a2754b7efe0e5 100644 (file)
 #include "kvm/util.h"
 
 struct cmd_struct kvm_commands[] = {
-       { "pause",      kvm_cmd_pause,          NULL,         0 },
-       { "resume",     kvm_cmd_resume,         NULL,         0 },
-       { "debug",      kvm_cmd_debug,          NULL,         0 },
-       { "balloon",    kvm_cmd_balloon,        NULL,         0 },
-       { "list",       kvm_cmd_list,           NULL,         0 },
-       { "version",    kvm_cmd_version,        NULL,         0 },
-       { "--version",  kvm_cmd_version,        NULL,         0 },
-       { "stop",       kvm_cmd_stop,           NULL,         0 },
-       { "help",       kvm_cmd_help,           NULL,         0 },
-       { "run",        kvm_cmd_run,            kvm_run_help, 0 },
-       { NULL,         NULL,                   NULL,         0 },
+       { "pause",      kvm_cmd_pause,          kvm_pause_help,         0 },
+       { "resume",     kvm_cmd_resume,         kvm_resume_help,        0 },
+       { "debug",      kvm_cmd_debug,          kvm_debug_help,         0 },
+       { "balloon",    kvm_cmd_balloon,        kvm_balloon_help,       0 },
+       { "list",       kvm_cmd_list,           kvm_list_help,          0 },
+       { "version",    kvm_cmd_version,        NULL,                   0 },
+       { "--version",  kvm_cmd_version,        NULL,                   0 },
+       { "stop",       kvm_cmd_stop,           kvm_stop_help,          0 },
+       { "help",       kvm_cmd_help,           NULL,                   0 },
+       { "run",        kvm_cmd_run,            kvm_run_help,           0 },
+       { NULL,         NULL,                   NULL,                   0 },
 };
 
 /*