From patchwork Fri May 16 15:30:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 349660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 99A3D140091 for ; Sat, 17 May 2014 01:37:42 +1000 (EST) Received: from localhost ([::1]:36400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlKCa-0006Qh-Jb for incoming@patchwork.ozlabs.org; Fri, 16 May 2014 11:37:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK6D-0003Uh-5K for qemu-devel@nongnu.org; Fri, 16 May 2014 11:31:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlK65-0006F9-Fi for qemu-devel@nongnu.org; Fri, 16 May 2014 11:31:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK65-0006Es-6D for qemu-devel@nongnu.org; Fri, 16 May 2014 11:30:57 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFUrF6011458 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 May 2014 11:30:53 -0400 Received: from localhost (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFUrDG019650; Fri, 16 May 2014 11:30:53 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 16 May 2014 11:30:34 -0400 Message-Id: <1400254235-9435-20-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1400254235-9435-1-git-send-email-lcapitulino@redhat.com> References: <1400254235-9435-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 19/20] monitor: Add netdev_del id argument completion. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hani Benhabiles Signed-off-by: Hani Benhabiles Reviewed-by: Stefan Hajnoczi Signed-off-by: Luiz Capitulino --- 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 a3dd361..593679a 100644 --- a/monitor.c +++ b/monitor.c @@ -4493,6 +4493,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,