qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/3] ide: add drive-id property


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH 1/3] ide: add drive-id property
Date: Fri, 26 Apr 2013 14:43:05 -0500

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]