From patchwork Fri Jun 10 00:59:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 9168721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9827760467 for ; Fri, 10 Jun 2016 01:00:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B99828363 for ; Fri, 10 Jun 2016 01:00:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8033D28369; Fri, 10 Jun 2016 01:00:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C75D28363 for ; Fri, 10 Jun 2016 01:00:44 +0000 (UTC) Received: from localhost ([::1]:37800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBAoV-0001vM-B1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Jun 2016 21:00:43 -0400 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 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp09.in.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Jun 2016 06:29:23 +0530 X-IBM-Helo: d28dlp01.in.ibm.com X-IBM-MailFrom: bharata@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;qemu-ppc@nongnu.org Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 5D9B0E0045; Fri, 10 Jun 2016 06:32:55 +0530 (IST) Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay05.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5A0wpaR20775318; Fri, 10 Jun 2016 06:28:51 +0530 Received: from d28av05.in.ibm.com (localhost [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5A0xJBi025150; Fri, 10 Jun 2016 06:29:22 +0530 Received: from bharata.in.ibm.com ([9.79.185.199]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u5A0xCpf024706; Fri, 10 Jun 2016 06:29:15 +0530 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Fri, 10 Jun 2016 06:29:00 +0530 X-Mailer: git-send-email 2.1.0 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> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16061000-0060-0000-0000-000000A1C793 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16061000-0061-0000-0000-00000D9C9958 Message-Id: <1465520348-13964-2-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-09_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=1 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606100011 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v4 1/9] 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: mjrosato@linux.vnet.ibm.com, thuth@redhat.com, pkrempa@redhat.com, ehabkost@redhat.com, aik@ozlabs.ru, Bharata B Rao , agraf@suse.de, mdroth@linux.vnet.ibm.com, borntraeger@de.ibm.com, qemu-ppc@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-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 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);