From patchwork Thu Aug 25 06:41:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peter A. G. Crosthwaite" X-Patchwork-Id: 111471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 44C25B6F72 for ; Thu, 25 Aug 2011 16:44:01 +1000 (EST) Received: from localhost ([::1]:43277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTfR-0001My-M8 for incoming@patchwork.ozlabs.org; Thu, 25 Aug 2011 02:43:57 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTf9-0000Zv-G2 for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:43:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwTf8-0003zg-Jd for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:43:39 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:57606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTf8-0003zb-GL for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:43:38 -0400 Received: by gyd12 with SMTP id 12so1700726gyd.4 for ; Wed, 24 Aug 2011 23:43:37 -0700 (PDT) Received: by 10.236.37.202 with SMTP id y50mr29414886yha.101.1314254617335; Wed, 24 Aug 2011 23:43:37 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id j45sm472056yhe.36.2011.08.24.23.43.33 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 24 Aug 2011 23:43:36 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com, edgar.iglesias@gmail.com, john.williams@petalogix.com, michal.simek@petalogix.com Date: Thu, 25 Aug 2011 16:41:12 +1000 Message-Id: <1314254480-22438-7-git-send-email-peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1314254480-22438-1-git-send-email-peter.crosthwaite@petalogix.com> References: <1314254480-22438-1-git-send-email-peter.crosthwaite@petalogix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.160.173 Cc: "Peter A. G. Crosthwaite" Subject: [Qemu-devel] [RFC PATCH V1 06/14] qdev: Added fn for querying device property types 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 Added a function qdev_get_prop_type(), which allows a machine model to query the type of a qdev prop of a device using a handle to the device, and the string name of the property Signed-off-by: Peter A. G. Crosthwaite --- hw/qdev-properties.c | 9 +++++++++ hw/qdev.h | 1 + 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 0c0c292..b5b2a78 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -583,6 +583,15 @@ int qdev_prop_exists(DeviceState *dev, const char *name) return qdev_prop_find(dev, name) ? true : false; } +int qdev_prop_get_type(DeviceState *dev, const char *name, enum PropertyType *ret) +{ + Property *prop = qdev_prop_find(dev, name); + if (!prop) + return 1; + *ret = prop->info->type; + return 0; +} + int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) { Property *prop; diff --git a/hw/qdev.h b/hw/qdev.h index 8a13ec9..79d9f9d 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -295,6 +295,7 @@ extern PropertyInfo qdev_prop_pci_devfn; /* Set properties between creation and init. */ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop); int qdev_prop_exists(DeviceState *dev, const char *name); +int qdev_prop_get_type(DeviceState *dev, const char *name, enum PropertyType *ret); int qdev_prop_parse(DeviceState *dev, const char *name, const char *value); void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type); void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);