From patchwork Sun Mar 30 10:58:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hani Benhabiles X-Patchwork-Id: 335090 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 912F71400C3 for ; Sun, 30 Mar 2014 22:00:00 +1100 (EST) Received: from localhost ([::1]:43702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUDT4-000089-DU for incoming@patchwork.ozlabs.org; Sun, 30 Mar 2014 06:59:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUDSJ-0008Ka-VD for qemu-devel@nongnu.org; Sun, 30 Mar 2014 06:59:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUDSC-0003Wy-Ml for qemu-devel@nongnu.org; Sun, 30 Mar 2014 06:59:11 -0400 Received: from mail-ee0-x230.google.com ([2a00:1450:4013:c00::230]:38961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUDSC-0003Wl-GM for qemu-devel@nongnu.org; Sun, 30 Mar 2014 06:59:04 -0400 Received: by mail-ee0-f48.google.com with SMTP id b57so5573103eek.35 for ; Sun, 30 Mar 2014 03:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xuNW3hXvioB8imMP2G3KY9j5h80bjaLeOJb6nu4zdOM=; b=WvlV6yCHhF7MGR3iBAI1Pr0/Yh2xCL8C6I7t646OnmjTQ+yWMZZREke0bUoy3iUFuh LJRqQh1KEfPsexHGXopQvpNk8Kufifz6NddWGKIMt6LLXKkoasy9uuBzG52+IImWOM7J M0z/YT7UV4hmSi4vtlb0sn0wrte32pagF04uu2Rf+mQIuA2rPJRUHgHjXNONb0ogDczU FVz/4nzS47bMSMUQjz7/Y4pUedVZXX7+B0zSLUZn0yuRaQGHoipl1H8XhNKhS61rWtL3 UsJHojF8zp8Ec/a+D4woWeSFkGAbegfVlAVOyPNx4ZZv6ByocIRMSJLEjd6x4Cy3+Ja7 8ijQ== X-Received: by 10.15.36.6 with SMTP id h6mr3707679eev.54.1396177143675; Sun, 30 Mar 2014 03:59:03 -0700 (PDT) Received: from localhost.localdomain ([41.109.152.17]) by mx.google.com with ESMTPSA id y51sm25023258eeu.0.2014.03.30.03.59.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 30 Mar 2014 03:59:03 -0700 (PDT) From: Hani Benhabiles To: qemu-devel@nongnu.org Date: Sun, 30 Mar 2014 11:58:31 +0100 Message-Id: <1396177119-24955-10-git-send-email-kroosec@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1396177119-24955-1-git-send-email-kroosec@gmail.com> References: <1396177119-24955-1-git-send-email-kroosec@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::230 Cc: kwolf@redhat.com, aliguori@amazon.com, lcapitulino@redhat.com, stefanha@redhat.com, imammedo@redhat.com Subject: [Qemu-devel] [PATCH v2 09/17] 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 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 b009561..d252ffc 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1244,6 +1244,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 9dab1a3..c98722b 100644 --- a/hmp.h +++ b/hmp.h @@ -102,5 +102,6 @@ void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str); void cpu_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 5293370..d1b0d6c 100644 --- a/monitor.c +++ b/monitor.c @@ -4505,6 +4505,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,