qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v6 23/27] ide: add bootindex to qom property


From: arei.gonglei
Subject: [Qemu-devel] [PATCH v6 23/27] ide: add bootindex to qom property
Date: Sat, 30 Aug 2014 18:00:23 +0800

From: Gonglei <address@hidden>

Add a qom property with the same name 'bootindex',
when we remove it form qdev property, things will
continue to work just fine, and we can use qom features
which are not supported by qdev property.

Signed-off-by: Gonglei <address@hidden>
---
 hw/ide/qdev.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 83bdb97..67ee098 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -196,6 +196,31 @@ static void ide_dev_reset(DeviceState *dev)
                          d->unit ? "/address@hidden" : "/address@hidden");
 }
 
+static void ide_dev_get_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
+
+    get_bootindex(&d->conf.bootindex, v, name, errp);
+}
+
+static void ide_dev_set_bootindex(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    DeviceState *dev = DEVICE(obj);
+    IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev);
+
+    set_bootindex(&d->conf.bootindex, v, name, errp);
+}
+
+static void ide_dev_instance_init(Object *obj)
+{
+    object_property_add(obj, "bootindex", "int",
+                        ide_dev_get_bootindex,
+                        ide_dev_set_bootindex, NULL, NULL, NULL);
+}
+
 static int ide_hd_initfn(IDEDevice *dev)
 {
     return ide_dev_initfn(dev, IDE_HD);
@@ -244,6 +269,7 @@ static const TypeInfo ide_hd_info = {
     .parent        = TYPE_IDE_DEVICE,
     .instance_size = sizeof(IDEDrive),
     .class_init    = ide_hd_class_init,
+    .instance_init = ide_dev_instance_init,
 };
 
 static Property ide_cd_properties[] = {
@@ -267,6 +293,7 @@ static const TypeInfo ide_cd_info = {
     .parent        = TYPE_IDE_DEVICE,
     .instance_size = sizeof(IDEDrive),
     .class_init    = ide_cd_class_init,
+    .instance_init = ide_dev_instance_init,
 };
 
 static Property ide_drive_properties[] = {
@@ -290,6 +317,7 @@ static const TypeInfo ide_drive_info = {
     .parent        = TYPE_IDE_DEVICE,
     .instance_size = sizeof(IDEDrive),
     .class_init    = ide_drive_class_init,
+    .instance_init = ide_dev_instance_init,
 };
 
 static void ide_device_class_init(ObjectClass *klass, void *data)
-- 
1.7.12.4





reply via email to

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