From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiAXE-0005Hx-Q8 for qemu-devel@nongnu.org; Wed, 07 May 2014 18:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiAX8-000358-RI for qemu-devel@nongnu.org; Wed, 07 May 2014 18:41:56 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:37812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiAX8-00034u-K8 for qemu-devel@nongnu.org; Wed, 07 May 2014 18:41:50 -0400 Received: by mail-wi0-f171.google.com with SMTP id hm4so9929140wib.4 for ; Wed, 07 May 2014 15:41:49 -0700 (PDT) From: Hani Benhabiles Date: Wed, 7 May 2014 23:41:32 +0100 Message-Id: <1399502492-6188-7-git-send-email-kroosec@gmail.com> In-Reply-To: <1399502492-6188-1-git-send-email-kroosec@gmail.com> References: <1399502492-6188-1-git-send-email-kroosec@gmail.com> Subject: [Qemu-devel] [PATCH 6/6] monitor: Add netdev_del id argument completion. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, lcapitulino@redhat.com Signed-off-by: Hani Benhabiles --- hmp-commands.hx | 1 + hmp.h | 1 + monitor.c | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index a7f9b2f..2e462c0 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1252,6 +1252,7 @@ ETEXI .params = "id", .help = "remove host network device", .mhandler.cmd = hmp_netdev_del, + .command_completion = netdev_del_completion, }, STEXI diff --git a/hmp.h b/hmp.h index bcecd0d..aba59e9 100644 --- a/hmp.h +++ b/hmp.h @@ -102,5 +102,6 @@ void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str); void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str); void set_link_completion(ReadLineState *rs, int nb_args, const char *str); void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str); +void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str); #endif diff --git a/monitor.c b/monitor.c index a4c429c..7f68549 100644 --- a/monitor.c +++ b/monitor.c @@ -4476,6 +4476,32 @@ void set_link_completion(ReadLineState *rs, int nb_args, const char *str) } } +void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) +{ + int len, count, i; + NetClientState *ncs[255]; + + if (nb_args != 2) { + return; + } + + len = strlen(str); + readline_set_completion_index(rs, len); + count = qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_OPTIONS_KIND_NIC, + 255); + for (i = 0; i < count; i++) { + QemuOpts *opts; + const char *name = ncs[i]->name; + if (strncmp(str, name, len)) { + continue; + } + opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), name); + if (opts) { + readline_add_completion(rs, name); + } + } +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args, -- 1.8.3.2