Received: from eggs.gnu.org ([2001:4830:134:3::10]:60648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNqPs-000849-9d for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNqPg-00005D-4n for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:20 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45525 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNqPf-0008Sa-TE for qemu-devel@nongnu.org; Wed, 12 Mar 2014 17:10:08 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 12 Mar 2014 22:10:01 +0100 Message-Id: <1394658603-13650-30-git-send-email-afaerber@suse.de> In-Reply-To: <1394658603-13650-1-git-send-email-afaerber@suse.de> References: <1394658603-13650-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 for-2.0-rc0 29/31] qdev: Realize buses on device realization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Bandan Das , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Bandan Das Integrate (un)realization of child buses with realization/unrealization of the device hosting them. Code in device_unparent() is reordered for unrealization of buses to work as part of device unrealization. That way no changes need to be made to bus instantiation. Signed-off-by: Bandan Das Signed-off-by: Andreas F=C3=A4rber --- hw/core/qdev.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 7e58259..9f0a522 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -716,6 +716,7 @@ static void device_set_realized(Object *obj, bool val= ue, Error **err) { DeviceState *dev =3D DEVICE(obj); DeviceClass *dc =3D DEVICE_GET_CLASS(dev); + BusState *bus; Error *local_err =3D NULL; =20 if (dev->hotplugged && !dc->hotpluggable) { @@ -749,14 +750,30 @@ static void device_set_realized(Object *obj, bool v= alue, Error **err) dev->instance_id_alias, dev->alias_required_for_versi= on); } + if (local_err =3D=3D NULL) { + QLIST_FOREACH(bus, &dev->child_bus, sibling) { + object_property_set_bool(OBJECT(bus), true, "realized", + &local_err); + if (local_err !=3D NULL) { + break; + } + } + } if (dev->hotplugged && local_err =3D=3D NULL) { device_reset(dev); } } else if (!value && dev->realized) { - if (qdev_get_vmsd(dev)) { + QLIST_FOREACH(bus, &dev->child_bus, sibling) { + object_property_set_bool(OBJECT(bus), false, "realized", + &local_err); + if (local_err !=3D NULL) { + break; + } + } + if (qdev_get_vmsd(dev) && local_err =3D=3D NULL) { vmstate_unregister(dev, qdev_get_vmsd(dev), dev); } - if (dc->unrealize) { + if (dc->unrealize && local_err =3D=3D NULL) { dc->unrealize(dev, &local_err); } } @@ -841,13 +858,13 @@ static void device_unparent(Object *obj) QObject *event_data; bool have_realized =3D dev->realized; =20 + if (dev->realized) { + object_property_set_bool(obj, false, "realized", NULL); + } while (dev->num_child_bus) { bus =3D QLIST_FIRST(&dev->child_bus); object_unparent(OBJECT(bus)); } - if (dev->realized) { - object_property_set_bool(obj, false, "realized", NULL); - } if (dev->parent_bus) { bus_remove_child(dev->parent_bus, dev); object_unref(OBJECT(dev->parent_bus)); --=20 1.8.4.5