Received: from eggs.gnu.org ([208.118.235.92]:46569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVoYV-0008Lf-IA for qemu-devel@nongnu.org; Fri, 26 Apr 2013 15:43:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVoYR-0006iM-Hp for qemu-devel@nongnu.org; Fri, 26 Apr 2013 15:43:39 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:47848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVoYR-0006iA-1G for qemu-devel@nongnu.org; Fri, 26 Apr 2013 15:43:35 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 27 Apr 2013 05:34:09 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 06F8A2CE804A for ; Sat, 27 Apr 2013 05:43:26 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3QJTlQw19464192 for ; Sat, 27 Apr 2013 05:29:48 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3QJhPRT004382 for ; Sat, 27 Apr 2013 05:43:25 +1000 From: Anthony Liguori Date: Fri, 26 Apr 2013 14:43:05 -0500 Message-Id: <1367005387-330-2-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1367005387-330-1-git-send-email-aliguori@us.ibm.com> References: <1367005387-330-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 1/3] ide: add drive-id property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori This returns a string similar to what the guest would display in something like Linux's /dev/disk/by-id/ path. Signed-off-by: Anthony Liguori --- hw/ide/qdev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 8a9a891..94b1664 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -270,6 +270,20 @@ static const TypeInfo ide_drive_info = { .class_init = ide_drive_class_init, }; +static char *ide_device_get_model(Object *obj, Error **errp) +{ + IDEDevice *dev = IDE_DEVICE(obj); + IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); + IDEState *s = bus->ifs + dev->unit; + + return g_strdup_printf("%s %s", s->drive_model_str, s->drive_serial_str); +} + +static void ide_device_initfn(Object *obj) +{ + object_property_add_str(obj, "drive-id", ide_device_get_model, NULL, NULL); +} + static void ide_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); @@ -285,6 +299,7 @@ static const TypeInfo ide_device_type_info = { .abstract = true, .class_size = sizeof(IDEDeviceClass), .class_init = ide_device_class_init, + .instance_init = ide_device_initfn, }; static void ide_register_types(void) -- 1.8.0