From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MR2tq-0002mR-1n for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MR2tk-0002j6-VZ for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:49 -0400 Received: from [199.232.76.173] (port=56675 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR2tk-0002j1-RH for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:44 -0400 Received: from mx2.redhat.com ([66.187.237.31]:36367) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MR2tk-00039Y-BK for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:44 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6FBhhIE013574 for ; Wed, 15 Jul 2009 07:43:43 -0400 From: Gerd Hoffmann Date: Wed, 15 Jul 2009 13:43:34 +0200 Message-Id: <1247658216-511-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1247658216-511-1-git-send-email-kraxel@redhat.com> References: <1247658216-511-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 4/6] qdev: add user-specified identifier to devices. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add id field to DeviceState. Make "info qtree" print it. This helps users and management apps identifying devices in monitor output, which is especially useful with otherwise identical devices such as two virtio disks. This patch doesn't add a way to set the id, followup patches will do. Signed-off-by: Gerd Hoffmann --- hw/qdev.c | 6 ++++-- hw/qdev.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 53e9b00..aa555fc 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -114,7 +114,8 @@ void qdev_init(DeviceState *dev) void qdev_free(DeviceState *dev) { LIST_REMOVE(dev, sibling); - free(dev); + qemu_free(dev->id); + qemu_free(dev); } /* Get a character (serial) device interface. */ @@ -266,7 +267,8 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props, static void qdev_print(Monitor *mon, DeviceState *dev, int indent) { BusState *child; - qdev_printf("dev: %s\n", dev->info->name); + qdev_printf("dev: %s, id \"%s\"\n", dev->info->name, + dev->id ? dev->id : ""); indent += 2; if (dev->num_gpio_in) { qdev_printf("gpio-in %d\n", dev->num_gpio_in); diff --git a/hw/qdev.h b/hw/qdev.h index 115c2d0..4c6e673 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -17,6 +17,7 @@ typedef struct BusInfo BusInfo; /* This structure should not be accessed directly. We declare it here so that it can be embedded in individual device state structures. */ struct DeviceState { + char *id; DeviceInfo *info; BusState *parent_bus; int num_gpio_out; -- 1.6.2.5