From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBXTD-0004Zi-PF for qemu-devel@nongnu.org; Thu, 06 Feb 2014 17:31:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WBXT5-0005ka-7X for qemu-devel@nongnu.org; Thu, 06 Feb 2014 17:30:55 -0500 Received: from mail-ee0-x236.google.com ([2a00:1450:4013:c00::236]:34716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WBXT5-0005kU-0m for qemu-devel@nongnu.org; Thu, 06 Feb 2014 17:30:47 -0500 Received: by mail-ee0-f54.google.com with SMTP id e53so1194088eek.13 for ; Thu, 06 Feb 2014 14:30:46 -0800 (PST) From: Hani Benhabiles Date: Thu, 6 Feb 2014 23:30:11 +0100 Message-Id: <1391725813-29514-3-git-send-email-kroosec@gmail.com> In-Reply-To: <1391725813-29514-1-git-send-email-kroosec@gmail.com> References: <1391725813-29514-1-git-send-email-kroosec@gmail.com> Subject: [Qemu-devel] [PATCH 2/4] monitor: Add device_add device argument completion. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com --- monitor.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/monitor.c b/monitor.c index f8c4cae..65410cb 100644 --- a/monitor.c +++ b/monitor.c @@ -4254,6 +4254,27 @@ static const char *next_arg_type(const char *typestr) return (p != NULL ? ++p : typestr); } +static void device_add_completion(ReadLineState *rs, const char *str) +{ + GSList *list, *elt; + size_t len; + + len = strlen(str); + readline_set_completion_index(rs, len); + list = elt = object_class_get_list(TYPE_DEVICE, false); + while (elt) { + const char *name; + DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data, + TYPE_DEVICE); + name = object_class_get_name(OBJECT_CLASS(dc)); + if (!strncmp(name, str, len)) { + readline_add_completion(rs, name); + } + elt = elt->next; + } + g_slist_free(list); +} + static void device_del_completion(ReadLineState *rs, BusState *bus, const char *str, size_t len) { @@ -4336,6 +4357,11 @@ static void monitor_find_completion_by_table(Monitor *mon, readline_set_completion_index(mon->rs, strlen(str)); bdrv_iterate(block_completion_it, &mbs); break; + case 'O': + if (!strcmp(cmd->name, "device_add") && nb_args == 2) { + device_add_completion(mon->rs, str); + } + break; case 's': case 'S': if (!strcmp(cmd->name, "sendkey")) { -- 1.8.3.2