From patchwork Tue Jul 10 06:16:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pingfan liu X-Patchwork-Id: 170071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0CB322C007A for ; Tue, 10 Jul 2012 17:16:36 +1000 (EST) Received: from localhost ([::1]:59719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoTkv-000888-Kp for incoming@patchwork.ozlabs.org; Tue, 10 Jul 2012 02:17:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoTkd-0007Yz-8I for qemu-devel@nongnu.org; Tue, 10 Jul 2012 02:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoTkY-0001L0-Lj for qemu-devel@nongnu.org; Tue, 10 Jul 2012 02:16:46 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:53439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoTkY-0001KV-FX for qemu-devel@nongnu.org; Tue, 10 Jul 2012 02:16:42 -0400 Received: by yenl1 with SMTP id l1so11769358yen.4 for ; Mon, 09 Jul 2012 23:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=k0oSSUjhjXLiDRTtgwACvc+HBerTlnh6aXShlzAogH0=; b=ZQ9OaAdi/hgpzIxBsPVQG9IPuMxTT5jHI687ymgTlZSei1YpJzqT/4PoXOFudMJJmq Vjy9cicJ/y+rrbEglU8wR9jXJHZEmvSxp8p7X4o9JiYytCtDcyarQMTXlKL7RHUNtfbx Yu8htL+CM+XbgeCx6DyNv1lcOJKkyP2DMLSKYMmN2hudSI4hcT1yWoENXqufHG6VGciM ClYyhxgkx61bVUV9DNuYf2FWQT5AiLAnB7e3Eoeg2smIBv1pSuEdzQhdzWbkdsk3eSHv wVX4/iFpVod4XS7STGCdY9GN6Flw1zgHIEO1Gq8q8gweWZqBBeewbTjLMa2vxcLaRabL AtLw== Received: by 10.66.90.67 with SMTP id bu3mr71029350pab.47.1341901000481; Mon, 09 Jul 2012 23:16:40 -0700 (PDT) Received: from localhost ([202.108.130.138]) by mx.google.com with ESMTPS id rd7sm29214060pbc.70.2012.07.09.23.16.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 23:16:39 -0700 (PDT) From: Liu Ping Fan To: qemu-devel@nongnu.org Date: Tue, 10 Jul 2012 14:16:04 +0800 Message-Id: <1341900967-4344-3-git-send-email-qemulist@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1341900967-4344-1-git-send-email-qemulist@gmail.com> References: <1341900967-4344-1-git-send-email-qemulist@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.173 Cc: Blue Swirl , Jan Kiszka , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori Subject: [Qemu-devel] [PATCH 2/5] qom: introduce object_is_type_str(), so we can judge its type. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Liu Ping Fan --- include/qemu/object.h | 2 ++ qom/object.c | 6 ++++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index 8b17776..a66e996 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -479,6 +479,8 @@ void object_initialize(void *obj, const char *typename); */ void object_finalize(void *obj); +bool object_is_type_str(Object *obj, const char *typename); + /** * object_dynamic_cast: * @obj: The object to cast. diff --git a/qom/object.c b/qom/object.c index 00bb3b0..6c27d90 100644 --- a/qom/object.c +++ b/qom/object.c @@ -425,6 +425,12 @@ static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type) return false; } +bool object_is_type_str(Object *obj, const char *typename) +{ + TypeImpl *target_type = type_get_by_name(typename); + return !target_type || type_is_ancestor(obj->class->type, target_type); +} + static bool object_is_type(Object *obj, TypeImpl *target_type) { return !target_type || type_is_ancestor(obj->class->type, target_type);