From patchwork Fri May 16 15:30:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 349654 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 3C288140090 for ; Sat, 17 May 2014 01:36:25 +1000 (EST) Received: from localhost ([::1]:36379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlKBL-00048L-7n for incoming@patchwork.ozlabs.org; Fri, 16 May 2014 11:36:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK6D-0003Uj-5E 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 1WlK64-0006Ed-BF for qemu-devel@nongnu.org; Fri, 16 May 2014 11:31:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlK63-0006E9-Ns for qemu-devel@nongnu.org; Fri, 16 May 2014 11:30:56 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFUoMs011437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 May 2014 11:30:52 -0400 Received: from localhost (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4GFUoZr020221; Fri, 16 May 2014 11:30:50 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 16 May 2014 11:30:30 -0400 Message-Id: <1400254235-9435-16-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.25 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 15/20] monitor: Add chardev-remove command 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 --- hmp-commands.hx | 1 + hmp.h | 1 + monitor.c | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index b4b23c8..ba88e2a 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1639,6 +1639,7 @@ ETEXI .params = "id", .help = "remove chardev", .mhandler.cmd = hmp_chardev_remove, + .command_completion = chardev_remove_completion, }, STEXI diff --git a/hmp.h b/hmp.h index 12e21e7..affc2b6 100644 --- a/hmp.h +++ b/hmp.h @@ -98,5 +98,6 @@ void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); void device_del_completion(ReadLineState *rs, int nb_args, const char *str); void sendkey_completion(ReadLineState *rs, int nb_args, const char *str); +void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str); #endif diff --git a/monitor.c b/monitor.c index cb9b2c2..55e5696 100644 --- a/monitor.c +++ b/monitor.c @@ -4339,6 +4339,29 @@ static void device_del_bus_completion(ReadLineState *rs, BusState *bus, } } +void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str) +{ + size_t len; + ChardevInfoList *list, *start; + + if (nb_args != 2) { + return; + } + len = strlen(str); + readline_set_completion_index(rs, len); + + start = list = qmp_query_chardev(NULL); + while (list) { + ChardevInfo *chr = list->value; + + if (!strncmp(chr->label, str, len)) { + readline_add_completion(rs, chr->label); + } + list = list->next; + } + qapi_free_ChardevInfoList(start); +} + void device_del_completion(ReadLineState *rs, int nb_args, const char *str) { size_t len;