From patchwork Mon Oct 6 11:38:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Guihua X-Patchwork-Id: 396781 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 B3D3A1400B2 for ; Mon, 6 Oct 2014 22:41:46 +1100 (EST) Received: from localhost ([::1]:51316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb6fg-0001pG-EW for incoming@patchwork.ozlabs.org; Mon, 06 Oct 2014 07:41:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb6dg-0007wf-1e for qemu-devel@nongnu.org; Mon, 06 Oct 2014 07:39:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xb6dZ-0000tc-Ev for qemu-devel@nongnu.org; Mon, 06 Oct 2014 07:39:39 -0400 Received: from [59.151.112.132] (port=34378 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xb6dZ-0000r5-1t for qemu-devel@nongnu.org; Mon, 06 Oct 2014 07:39:33 -0400 X-IronPort-AV: E=Sophos;i="5.04,663,1406563200"; d="scan'208";a="36861857" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 06 Oct 2014 19:36:25 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s96BdT6m032665; Mon, 6 Oct 2014 19:39:29 +0800 Received: from G08FNSTD140041.fnst.cn.fujitsu.com (10.167.226.252) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 6 Oct 2014 19:39:31 +0800 From: Zhu Guihua To: Date: Mon, 6 Oct 2014 19:38:44 +0800 Message-ID: <5121b7eb590291a65e698afd1e55f2a1f5a0b8ab.1412594742.git.zhugh.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.252] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: peter.crosthwaite@xilinx.com, Zhu Guihua , mst@redhat.com, hutao@cn.fujitsu.com, armbru@redhat.com, lcapitulino@redhat.com, isimatu.yasuaki@jp.fujitsu.com, kroosec@gmail.com, imammedo@redhat.com, pbonzini@redhat.com, tangchen@cn.fujitsu.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v3 2/2] monitor: add del completion for peripheral device 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 Add peripheral_device_del_completion() to let peripheral device del completion be possible. Signed-off-by: Zhu Guihua --- monitor.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/monitor.c b/monitor.c index 667efb7..ffe5405 100644 --- a/monitor.c +++ b/monitor.c @@ -4351,6 +4351,29 @@ static void device_del_bus_completion(ReadLineState *rs, BusState *bus, } } +static void peripheral_device_del_completion(ReadLineState *rs, + const char *str, size_t len) +{ + Object *peripheral; + GSList *list = NULL, *item; + + peripheral = object_resolve_path("/machine/peripheral/", NULL); + + if (peripheral == NULL) { + return; + } + + object_child_foreach(peripheral, qdev_build_hotpluggable_device_list, + &list); + + for (item = list; item; item = g_slist_next(item)) { + DeviceState *dev = item->data; + if (!strncmp(str, dev->id, len)) { + readline_add_completion(rs, dev->id); + } + } +} + void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str) { size_t len; @@ -4424,6 +4447,7 @@ void device_del_completion(ReadLineState *rs, int nb_args, const char *str) len = strlen(str); readline_set_completion_index(rs, len); device_del_bus_completion(rs, sysbus_get_default(), str, len); + peripheral_device_del_completion(rs, str, len); } void object_del_completion(ReadLineState *rs, int nb_args, const char *str)