From patchwork Mon Jan 21 12:30:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 214155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E1D302C007B for ; Tue, 22 Jan 2013 00:49:11 +1100 (EST) Received: from localhost ([::1]:42619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGXE-0006S9-Pr for incoming@patchwork.ozlabs.org; Mon, 21 Jan 2013 07:31:32 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGWW-0005Iu-6c for qemu-devel@nongnu.org; Mon, 21 Jan 2013 07:30:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TxGWU-0006fa-Fs for qemu-devel@nongnu.org; Mon, 21 Jan 2013 07:30:48 -0500 Received: from mail-ee0-f49.google.com ([74.125.83.49]:62292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGWU-0006fP-8c for qemu-devel@nongnu.org; Mon, 21 Jan 2013 07:30:46 -0500 Received: by mail-ee0-f49.google.com with SMTP id d4so2767118eek.36 for ; Mon, 21 Jan 2013 04:30:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=D8cJGWOk/mVGnCFr+1dGTCAUVBJpryj8l14Hob0kwF8=; b=mSrwk2A5f4P/NBW8HIw5XakaEQfnhoSFtCxqBjzg2s9gUQ5O8bEC6rOmUB/sZv/Yfq ZPDBjuWjygmNROHyxG+m8kDyZvJ3iFdON5u03B6qLHwPAT4z5fQUJoq0nWtK8Btvu970 TB0TwBU1t/tvVyp74pwflyHTs8UJfAaQsduPwISjrfjOnP7qe6EdIwTS24Ng5AsP8GzQ vVwUyUxN2oRo5tgSLdIeAfuuaaMv9dtw7Go/MlU7x5Z/ychi0DIGActDbT4pD9lLsCCH 3ERUbEYKUmlM5UZUsuSOg8Fj4jCykPtgPNc4UNZMmuyRifUQCfOHIbh+lxBaW1ljQ9Sy SvEA== X-Received: by 10.14.178.196 with SMTP id f44mr60267733eem.14.1358771445419; Mon, 21 Jan 2013 04:30:45 -0800 (PST) Received: from yakj.lan (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id 46sm22102581eeg.4.2013.01.21.04.30.43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 21 Jan 2013 04:30:44 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 21 Jan 2013 13:30:18 +0100 Message-Id: <1358771422-14282-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1358771422-14282-1-git-send-email-pbonzini@redhat.com> References: <1358771422-14282-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.83.49 Cc: aliguori@us.ibm.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 08/12] qdev: add reference for the bus while it is referred to by the DeviceState 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 Now that the unparent callbacks are complete, we can correctly account more missing references. Signed-off-by: Paolo Bonzini --- hw/qdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/qdev.c b/hw/qdev.c index aad360f..24bb19a 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -100,6 +100,7 @@ static void bus_add_child(BusState *bus, DeviceState *child) void qdev_set_parent_bus(DeviceState *dev, BusState *bus) { dev->parent_bus = bus; + object_ref(OBJECT(bus)); bus_add_child(bus, dev); } @@ -773,6 +774,8 @@ static void device_unparent(Object *obj) } if (dev->parent_bus) { bus_remove_child(dev->parent_bus, dev); + object_unref(OBJECT(dev->parent_bus)); + dev->parent_bus = NULL; } }