From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeEyE-0006MP-Je for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeEy2-0004vR-67 for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:50 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49361 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeEy2-0004rQ-0O for qemu-devel@nongnu.org; Tue, 14 Oct 2014 23:09:38 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 15 Oct 2014 05:09:16 +0200 Message-Id: <1413342561-4754-43-git-send-email-afaerber@suse.de> In-Reply-To: <1413342561-4754-1-git-send-email-afaerber@suse.de> References: <1413342561-4754-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 42/47] qdev: device_del: Search for to be unplugged device in 'peripheral' container List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Igor Mammedov device_add puts every device with 'id' inside of 'peripheral' container using id's value as the last component name. Use it by replacing recursive search on sysbus with path lookup in 'peripheral' container, which could handle both BUS and BUS-less device cases. Signed-off-by: Igor Mammedov Signed-off-by: Andreas F=C3=A4rber --- qdev-monitor.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/qdev-monitor.c b/qdev-monitor.c index c721451..754437b 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -686,15 +686,20 @@ int do_device_add(Monitor *mon, const QDict *qdict,= QObject **ret_data) =20 void qmp_device_del(const char *id, Error **errp) { - DeviceState *dev; + Object *obj; + char *root_path =3D object_get_canonical_path(qdev_get_peripheral())= ; + char *path =3D g_strdup_printf("%s/%s", root_path, id); =20 - dev =3D qdev_find_recursive(sysbus_get_default(), id); - if (!dev) { + g_free(root_path); + obj =3D object_resolve_path_type(path, TYPE_DEVICE, NULL); + g_free(path); + + if (!obj) { error_set(errp, QERR_DEVICE_NOT_FOUND, id); return; } =20 - qdev_unplug(dev, errp); + qdev_unplug(DEVICE(obj), errp); } =20 void qdev_machine_init(void) --=20 1.8.4.5