summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-10-07 16:00:29 +0800
committerGerd Hoffmann <kraxel@redhat.com>2014-10-15 09:52:55 +0200
commit4556363087e21bedab006aa5a5803399d2277eac (patch)
tree787d17acdddaf14d905bb3fb22f4a46be799f659 /hw
parent44fb6337b9568ccb9f0d6dfb357eeb69f66d8527 (diff)
downloadhqemu-4556363087e21bedab006aa5a5803399d2277eac.zip
hqemu-4556363087e21bedab006aa5a5803399d2277eac.tar.gz
ide: add bootindex to qom property
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 <arei.gonglei@huawei.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/ide/qdev.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index efab95b..7e69020 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -23,6 +23,7 @@
#include "sysemu/blockdev.h"
#include "hw/block/block.h"
#include "sysemu/sysemu.h"
+#include "qapi/visitor.h"
/* --------------------------------- */
@@ -191,6 +192,46 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
return 0;
}
+static void ide_dev_get_bootindex(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ IDEDevice *d = IDE_DEVICE(obj);
+
+ visit_type_int32(v, &d->conf.bootindex, name, errp);
+}
+
+static void ide_dev_set_bootindex(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ IDEDevice *d = IDE_DEVICE(obj);
+ int32_t boot_index;
+ Error *local_err = NULL;
+
+ visit_type_int32(v, &boot_index, name, &local_err);
+ if (local_err) {
+ goto out;
+ }
+ /* check whether bootindex is present in fw_boot_order list */
+ check_boot_index(boot_index, &local_err);
+ if (local_err) {
+ goto out;
+ }
+ /* change bootindex to a new one */
+ d->conf.bootindex = boot_index;
+
+out:
+ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+}
+
+static void ide_dev_instance_init(Object *obj)
+{
+ object_property_add(obj, "bootindex", "int32",
+ 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);
@@ -300,6 +341,7 @@ static const TypeInfo ide_device_type_info = {
.abstract = true,
.class_size = sizeof(IDEDeviceClass),
.class_init = ide_device_class_init,
+ .instance_init = ide_dev_instance_init,
};
static void ide_register_types(void)
OpenPOWER on IntegriCloud