From patchwork Mon Dec 12 20:18:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 130908 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 4A8FE1007D4 for ; Tue, 13 Dec 2011 09:23:59 +1100 (EST) Received: from localhost ([::1]:58632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCPO-00058v-Sx for incoming@patchwork.ozlabs.org; Mon, 12 Dec 2011 15:23:34 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCP3-0003w3-Du for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:23:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaCOx-0000h2-Gq for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:23:08 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:44565 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCOx-0000gw-96 for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:23:07 -0500 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id pBCKMx7n032591; Mon, 12 Dec 2011 14:23:00 -0600 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id pBCKMvd0032589; Mon, 12 Dec 2011 14:22:57 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 12 Dec 2011 14:18:18 -0600 Message-Id: <1323721273-32404-23-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> References: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Kevin Wolf , Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Jan Kiszka , Markus Armbruster , Luiz Capitulino Subject: [Qemu-devel] [PATCH v3 022/197] qdev: add a qdev_get_type() function and expose as a 'type' property 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: Anthony Liguori --- hw/qdev.c | 7 +++++++ hw/qdev.h | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 0fc20fc..83913c7 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -110,6 +110,8 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) qdev_property_add_legacy(dev, prop, NULL); } + qdev_property_add_str(dev, "type", qdev_get_type, NULL, NULL); + return dev; } @@ -1031,6 +1033,11 @@ char* qdev_get_fw_dev_path(DeviceState *dev) return strdup(path); } +char *qdev_get_type(DeviceState *dev, Error **errp) +{ + return g_strdup(dev->info->name); +} + void qdev_ref(DeviceState *dev) { dev->ref++; diff --git a/hw/qdev.h b/hw/qdev.h index 9faf2ee..6e18427 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -596,4 +596,18 @@ void qdev_property_add_str(DeviceState *dev, const char *name, void (*set)(DeviceState *, const char *, Error **), Error **errp); +/** + * @qdev_get_type + * + * Returns the string representation of the type of this object. + * + * @dev - the device + * + * @errp - if an error occurs, a pointer to an area to store the error + * + * Returns: a string representing the type. This must be freed by the caller + * with g_free(). + */ +char *qdev_get_type(DeviceState *dev, Error **errp); + #endif