From patchwork Tue Dec 24 17:04:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 305038 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 98F2C2C00A0 for ; Wed, 25 Dec 2013 05:02:08 +1100 (EST) Received: from localhost ([::1]:39683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvVXs-0008S2-3T for incoming@patchwork.ozlabs.org; Tue, 24 Dec 2013 12:13:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvVPW-00063n-En for qemu-devel@nongnu.org; Tue, 24 Dec 2013 12:04:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VvVPO-00047l-MK for qemu-devel@nongnu.org; Tue, 24 Dec 2013 12:04:50 -0500 Received: from cantor2.suse.de ([195.135.220.15]:54393 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvVPO-00044c-Gc for qemu-devel@nongnu.org; Tue, 24 Dec 2013 12:04:42 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 48DE4AC1F; Tue, 24 Dec 2013 17:04:42 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 24 Dec 2013 18:04:29 +0100 Message-Id: <1387904675-7962-19-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1387904675-7962-1-git-send-email-afaerber@suse.de> References: <1387904675-7962-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Stefan Hajnoczi , "Michael S. Tsirkin" Subject: [Qemu-devel] [PULL v2 18/24] qdev: Drop misleading qbus_free() function 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: Stefan Hajnoczi Same reasoning as commit 02a5c4c97422b40034f31265e0f139f7846172a8 ("qdev: Drop misleading qdev_free() function"). The qbus_free() function removes the child from the namespace and decrements the reference count. It does not, however, guarantee to free the child since the refcount may still be held. Just call object_unparent() directly. Suggested-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi Signed-off-by: Andreas Färber --- hw/core/qdev.c | 7 +------ hw/pci/pci_bridge.c | 2 +- include/hw/qdev-core.h | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index e374a93..bbd780a 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -481,11 +481,6 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam return bus; } -void qbus_free(BusState *bus) -{ - object_unparent(OBJECT(bus)); -} - static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev) { BusClass *bc = BUS_GET_CLASS(bus); @@ -794,7 +789,7 @@ static void device_unparent(Object *obj) while (dev->num_child_bus) { bus = QLIST_FIRST(&dev->child_bus); - qbus_free(bus); + object_unparent(OBJECT(bus)); } if (dev->realized) { object_property_set_bool(obj, false, "realized", NULL); diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index f72872e..355c3e1 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -391,7 +391,7 @@ void pci_bridge_exitfn(PCIDevice *pci_dev) pci_bridge_region_cleanup(s, s->windows); memory_region_destroy(&s->address_space_mem); memory_region_destroy(&s->address_space_io); - /* qbus_free() is called automatically during device deletion */ + /* object_unparent() is called automatically during device deletion */ } /* diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index c8945a4..651c3e5 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -283,8 +283,6 @@ void qdev_reset_all(DeviceState *dev); void qbus_reset_all(BusState *bus); void qbus_reset_all_fn(void *opaque); -void qbus_free(BusState *bus); - /* This should go away once we get rid of the NULL bus hack */ BusState *sysbus_get_default(void);