From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2Juq-0001ch-LF for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:04:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2Jug-0000ba-NW for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:04:16 -0500 Received: from mail-pw0-f45.google.com ([209.85.160.45]:57267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2Jug-0000bD-BT for qemu-devel@nongnu.org; Tue, 28 Feb 2012 05:04:06 -0500 Received: by pbcuo1 with SMTP id uo1so11666pbc.4 for ; Tue, 28 Feb 2012 02:04:04 -0800 (PST) Sender: Paolo Bonzini Message-ID: <4F4CA68D.8050800@redhat.com> Date: Tue, 28 Feb 2012 11:03:57 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1330413510-9289-1-git-send-email-i.mitsyanko@samsung.com> <4F4CA1DD.6080905@samsung.com> In-Reply-To: <4F4CA1DD.6080905@samsung.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qom: if @instance_size==0, assign size of object to parent object size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: i.mitsyanko@samsung.com Cc: qemu-devel@nongnu.org Il 28/02/2012 10:43, Igor Mitsyanko ha scritto: > On 02/28/2012 12:39 PM, Paolo Bonzini wrote: >> Il 28/02/2012 08:18, Igor Mitsyanko ha scritto: >>> QOM documentation states that for objects of type with @instance_size >>> == 0 size >>> will be assigned to match parent object's size. But currently this >>> feauture is >>> not implemented and qemu asserts during creation of object with zero >>> instance_size. >>> This patch adjusts actual behaviour in accordance with documentation. >> >> You can do it just once, in type_get_parent instead. Sorry, rewind. "You can do it in type_class_init instead" (you are obviously doing it just once since you assign to type->instance_size). type_class_init mostly deals with class initialization, but it's really the place where a type is hooked up with its parent. Perhaps type_late_init would be a better name. I think the problem is misplaced type_class_init calls. void object_initialize(void *data, const char *typename) { TypeImpl *type = type_get_by_name(typename); + type->instance_size = object_get_instance_size(type); object_initialize_with_type(data, type); } object_initialize_with_type needs to call type_class_init before testing type->instance_size, not after. @@ -357,6 +371,7 @@ Object *object_new_with_type(Type type) g_assert(type != NULL); + type->instance_size = object_get_instance_size(type); And this should also be a call to type_class_init. obj = g_malloc(type->instance_size); object_initialize_with_type(obj, type); object_ref(obj); Paolo