From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPWpH-0007DH-C0 for qemu-devel@nongnu.org; Tue, 09 Apr 2013 07:35:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPWpG-00043R-93 for qemu-devel@nongnu.org; Tue, 09 Apr 2013 07:34:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPWpF-00043H-V0 for qemu-devel@nongnu.org; Tue, 09 Apr 2013 07:34:58 -0400 Message-ID: <5163FCCF.7040006@redhat.com> Date: Tue, 09 Apr 2013 13:34:39 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1365172636-28628-1-git-send-email-imammedo@redhat.com> <1365172636-28628-23-git-send-email-imammedo@redhat.com> In-Reply-To: <1365172636-28628-23-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 20/22] qdev: set device's parent before calling realize() down inheritance chain. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: aliguori@us.ibm.com, ehabkost@redhat.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, aderumier@odiso.com, lcapitulino@redhat.com, jfrei@linux.vnet.ibm.com, yang.z.zhang@intel.com, afaerber@suse.de, lig.fnst@cn.fujitsu.com, rth@twiddle.net Il 05/04/2013 16:37, Igor Mammedov ha scritto: > Currently device_set_realized() sets parent only after device was realized, > But qdev_device_add() sets it before device is realized. > Make behavior consistent and alter device_set_realized() to behave like > qdev_device_add(). > > It will allow to set link<> properties in realize() method in classes > inherited from DEVICE. > > Signed-off-by: Igor Mammedov > --- > * Usage examples > - conversion to CPU back-link property in APIC > - pre-allocate link at board level, and populate them > at realize time when CPUs are created. > --- > hw/qdev.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index e2bb37d..b9bd6f5 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -671,10 +671,6 @@ static void device_set_realized(Object *obj, bool value, Error **err) > Error *local_err = NULL; > > if (value && !dev->realized) { > - if (dc->realize) { > - dc->realize(dev, &local_err); > - } > - > if (!obj->parent && local_err == NULL) { > static int unattached_count; > gchar *name = g_strdup_printf("device[%d]", unattached_count++); > @@ -685,6 +681,10 @@ static void device_set_realized(Object *obj, bool value, Error **err) > g_free(name); > } > > + if (dc->realize) { > + dc->realize(dev, &local_err); > + } > + > if (qdev_get_vmsd(dev) && local_err == NULL) { > vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, > dev->instance_id_alias, > Reviewed-by: Paolo Bonzini