From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBAnU-0001XC-QR for qemu-devel@nongnu.org; Thu, 09 Jun 2016 20:59:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBAnK-0008Ev-FK for qemu-devel@nongnu.org; Thu, 09 Jun 2016 20:59:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:24655 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBAnK-0008Dr-AV for qemu-devel@nongnu.org; Thu, 09 Jun 2016 20:59:30 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5A0xE2f087876 for ; Thu, 9 Jun 2016 20:59:28 -0400 Received: from e28smtp09.in.ibm.com (e28smtp09.in.ibm.com [125.16.236.9]) by mx0a-001b2d01.pphosted.com with ESMTP id 23e9m4sg5f-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 09 Jun 2016 20:59:28 -0400 Received: from localhost by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Jun 2016 06:29:25 +0530 From: Bharata B Rao Date: Fri, 10 Jun 2016 06:29:00 +0530 In-Reply-To: <1465520348-13964-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1465520348-13964-1-git-send-email-bharata@linux.vnet.ibm.com> Message-Id: <1465520348-13964-2-git-send-email-bharata@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v4 1/9] qom: API to get instance_size of a type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, imammedo@redhat.com, thuth@redhat.com, aik@ozlabs.ru, agraf@suse.de, pbonzini@redhat.com, ehabkost@redhat.com, pkrempa@redhat.com, mdroth@linux.vnet.ibm.com, eblake@redhat.com, mjrosato@linux.vnet.ibm.com, borntraeger@de.ibm.com, Bharata B Rao Add an API object_type_get_size(const char *typename) that returns the instance_size of the give typename. Signed-off-by: Bharata B Rao --- include/qom/object.h | 8 +++++++- qom/object.c | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/qom/object.h b/include/qom/object.h index 21bb5ff..460ddfc 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1608,5 +1608,11 @@ int object_child_foreach_recursive(Object *obj, */ Object *container_get(Object *root, const char *path); - +/** + * object_type_get_size: + * @typename: Name of the Type whose instance_size is required + * + * Returns the instance_size of the given @typename. + */ +size_t object_type_get_size(const char *typename); #endif diff --git a/qom/object.c b/qom/object.c index 3bc8a00..0e75877 100644 --- a/qom/object.c +++ b/qom/object.c @@ -202,6 +202,14 @@ static size_t type_object_get_size(TypeImpl *ti) return 0; } +size_t object_type_get_size(const char *typename) +{ + TypeImpl *type = type_get_by_name(typename); + + g_assert(type != NULL); + return type_object_get_size(type); +} + static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type) { assert(target_type); -- 2.1.0