From patchwork Thu Feb 13 15:30:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 320117 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 0A6A22C00BC for ; Fri, 14 Feb 2014 03:20:47 +1100 (EST) Received: from localhost ([::1]:47149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyM3-0001n0-7Y for incoming@patchwork.ozlabs.org; Thu, 13 Feb 2014 10:37:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyGP-0002Ga-N5 for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:31:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDyGJ-0000C7-Br for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:31:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDyGI-0000Bh-Ul for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:31:39 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1DFVZYM017151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Feb 2014 10:31:35 -0500 Received: from localhost (ovpn-113-138.phx2.redhat.com [10.3.113.138]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1DFVZf1000547; Thu, 13 Feb 2014 10:31:35 -0500 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Thu, 13 Feb 2014 10:30:37 -0500 Message-Id: <1392305440-30465-20-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1392305440-30465-1-git-send-email-lcapitulino@redhat.com> References: <1392305440-30465-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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/22] monitor: Add device_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 Signed-off-by: Luiz Capitulino --- monitor.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/monitor.c b/monitor.c index 690c152..c90fc1d 100644 --- a/monitor.c +++ b/monitor.c @@ -4254,6 +4254,25 @@ static const char *next_arg_type(const char *typestr) return (p != NULL ? ++p : typestr); } +static void device_del_completion(ReadLineState *rs, BusState *bus, + const char *str, size_t len) +{ + BusChild *kid; + + QTAILQ_FOREACH(kid, &bus->children, sibling) { + DeviceState *dev = kid->child; + BusState *dev_child; + + if (dev->id && !strncmp(str, dev->id, len)) { + readline_add_completion(rs, dev->id); + } + + QLIST_FOREACH(dev_child, &dev->child_bus, sibling) { + device_del_completion(rs, dev_child, str, len); + } + } +} + static void monitor_find_completion_by_table(Monitor *mon, const mon_cmd_t *cmd_table, char **args, @@ -4330,6 +4349,10 @@ static void monitor_find_completion_by_table(Monitor *mon, } else if (!strcmp(cmd->name, "help|?")) { monitor_find_completion_by_table(mon, cmd_table, &args[1], nb_args - 1); + } else if (!strcmp(cmd->name, "device_del") && nb_args == 2) { + size_t len = strlen(str); + readline_set_completion_index(mon->rs, len); + device_del_completion(mon->rs, sysbus_get_default(), str, len); } break; default: