From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbTRh-0007Xl-U5 for qemu-devel@nongnu.org; Tue, 07 Oct 2014 08:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XbTRb-00036Z-9O for qemu-devel@nongnu.org; Tue, 07 Oct 2014 08:00:49 -0400 Received: from [59.151.112.132] (port=49398 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbTRY-00034b-1J for qemu-devel@nongnu.org; Tue, 07 Oct 2014 08:00:43 -0400 Message-ID: <1412683191.18043.7.camel@G08FNSTD140041> From: Zhu Guihua Date: Tue, 7 Oct 2014 19:59:51 +0800 In-Reply-To: <1412244525-7153-1-git-send-email-imammedo@redhat.com> References: <1411723721-20484-1-git-send-email-imammedo@redhat.com> <1412244525-7153-1-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 37/36] 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: Igor Mammedov Cc: pbonzini@redhat.com, Peter Crosthwaite , Bharata B Rao , qemu-devel@nongnu.org, Andreas =?ISO-8859-1?Q?F=E4rber?= On Thu, 2014-10-02 at 10:08 +0000, Igor Mammedov wrote: > 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. > If I want to delete device without id inside of 'peripheral-anon' container, the command 'device_del' does not work. My suggestion is deleting device by the last component name, is this feasiable? Thanks. Zhu > Signed-off-by: Igor Mammedov > --- > 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) > > void qmp_device_del(const char *id, Error **errp) > { > - DeviceState *dev; > + Object *obj; > + char *root_path = object_get_canonical_path(qdev_get_peripheral()); > + char *path = g_strdup_printf("%s/%s", root_path, id); > > - dev = qdev_find_recursive(sysbus_get_default(), id); > - if (!dev) { > + g_free(root_path); > + obj = object_resolve_path_type(path, TYPE_DEVICE, NULL); > + g_free(path); > + > + if (!obj) { > error_set(errp, QERR_DEVICE_NOT_FOUND, id); > return; > } > > - qdev_unplug(dev, errp); > + qdev_unplug(DEVICE(obj), errp); > } > > void qdev_machine_init(void)