From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmWYi-0005cQ-6O for qemu-devel@nongnu.org; Mon, 19 May 2014 19:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmWYc-0005lO-81 for qemu-devel@nongnu.org; Mon, 19 May 2014 19:01:28 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:62060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmWYc-0005l9-1s for qemu-devel@nongnu.org; Mon, 19 May 2014 19:01:22 -0400 Received: by mail-wi0-f173.google.com with SMTP id bs8so4975425wib.12 for ; Mon, 19 May 2014 16:01:21 -0700 (PDT) From: Hani Benhabiles Date: Tue, 20 May 2014 00:01:04 +0100 Message-Id: <1400540468-1177-4-git-send-email-kroosec@gmail.com> In-Reply-To: <1400540468-1177-1-git-send-email-kroosec@gmail.com> References: <1400540468-1177-1-git-send-email-kroosec@gmail.com> Subject: [Qemu-devel] [PATCH 3/7] monitor: Add migrate_set_capability completion. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Hani Benhabiles --- hmp-commands.hx | 1 + hmp.h | 2 ++ monitor.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 45e1763..919af6e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -975,6 +975,7 @@ ETEXI .params = "capability state", .help = "Enable/Disable the usage of a capability for migration", .mhandler.cmd = hmp_migrate_set_capability, + .command_completion = migrate_set_capability_completion, }, STEXI diff --git a/hmp.h b/hmp.h index a70804d..0c814d0 100644 --- a/hmp.h +++ b/hmp.h @@ -107,5 +107,7 @@ void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str); void ringbuf_read_completion(ReadLineState *rs, int nb_args, const char *str); void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str); +void migrate_set_capability_completion(ReadLineState *rs, int nb_args, + const char *str); #endif diff --git a/monitor.c b/monitor.c index fb300c2..6a3a5c9 100644 --- a/monitor.c +++ b/monitor.c @@ -4572,6 +4572,27 @@ void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str) add_completion_option(rs, str, "none"); } +void migrate_set_capability_completion(ReadLineState *rs, int nb_args, + const char *str) +{ + size_t len; + + len = strlen(str); + readline_set_completion_index(rs, len); + if (nb_args == 2) { + int i; + for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) { + const char *name = MigrationCapability_lookup[i]; + if (!strncmp(str, name, len)) { + readline_add_completion(rs, name); + } + } + } else if (nb_args == 3) { + add_completion_option(rs, str, "on"); + add_completion_option(rs, str, "off"); + } +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args, -- 1.8.3.2