From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: "Peter A. G. Crosthwaite" Date: Thu, 25 Aug 2011 16:41:12 +1000 Message-Id: <1314254480-22438-7-git-send-email-peter.crosthwaite@petalogix.com> In-Reply-To: <1314254480-22438-1-git-send-email-peter.crosthwaite@petalogix.com> References: <1314254480-22438-1-git-send-email-peter.crosthwaite@petalogix.com> Subject: [Qemu-devel] [RFC PATCH V1 06/14] qdev: Added fn for querying device property types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com, edgar.iglesias@gmail.com, john.williams@petalogix.com, michal.simek@petalogix.com Cc: "Peter A. G. Crosthwaite" 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); -- 1.7.3.2