From patchwork Fri Jun 17 06:36:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 636808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rW9kc6kZsz9t1l for ; Fri, 17 Jun 2016 16:46:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b=iMna5+9x; dkim-atps=neutral Received: from localhost ([::1]:54250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDnXS-0008Hw-Mt for incoming@patchwork.ozlabs.org; Fri, 17 Jun 2016 02:45:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDnN3-0005bI-V8 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 02:35:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDnMy-0008Et-44 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 02:35:12 -0400 Received: from ozlabs.org ([103.22.144.67]:33335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDnMx-0008D7-PV; Fri, 17 Jun 2016 02:35:08 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3rW9Tt6sxMz9t2F; Fri, 17 Jun 2016 16:34:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1466145298; bh=1E/PImmPB2M2MPEVQTnFNxgMrDA7ZCF6vh0dUbi39JM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iMna5+9x0a+5cCJ5N4/OjEBPDTMNmsMO8SZzBtMaBHqtUjwEna1e4Q2KQxDMcLUV/ qgZfF4Ts3rAkuA8FZL7v+YdQ9GwM24pTFUfJI4BLSTnzBK5mYLCGk6AwU/HwLVxFMh Q7ySXU4rAxg0+HKylZNJZQlIEa0u6QOFIenjMFrA= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 17 Jun 2016 16:36:31 +1000 Message-Id: <1466145399-32209-11-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466145399-32209-1-git-send-email-david@gibson.dropbear.id.au> References: <1466145399-32209-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 10/18] qom: API to get instance_size of a type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, imammedo@redhat.com, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: 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 Signed-off-by: David Gibson --- 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 99de539..2f8ac47 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1607,5 +1607,11 @@ int object_child_foreach_recursive(Object *obj, */ Object *container_get(Object *root, const char *path); - +/** + * object_type_get_instance_size: + * @typename: Name of the Type whose instance_size is required + * + * Returns the instance_size of the given @typename. + */ +size_t object_type_get_instance_size(const char *typename); #endif diff --git a/qom/object.c b/qom/object.c index 3bc8a00..0311414 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_instance_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);