[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v11 25/34] ide: add bootindex to qom property
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v11 25/34] ide: add bootindex to qom property |
Date: |
Tue, 7 Oct 2014 16:00:29 +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>
Reviewed-by: Gerd Hoffmann <address@hidden>
---
hw/ide/qdev.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
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)
--
1.7.12.4
- [Qemu-devel] [PATCH v11 33/34] bootindex: delete bootindex when device is removed, (continued)
- [Qemu-devel] [PATCH v11 33/34] bootindex: delete bootindex when device is removed, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 05/34] bootindex: rework add_boot_device_path function, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 04/34] fw_cfg: add fw_cfg_machine_reset function, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 17/34] net: remove bootindex property from qdev to qom, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 28/34] virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 34/34] bootindex: change fprintf to error_report, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 23/34] isa-fdc: remove bootindexA/B property from qdev to qom, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 25/34] ide: add bootindex to qom property,
arei.gonglei <=
- [Qemu-devel] [PATCH v11 29/34] usb-storage: add bootindex to qom property, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 32/34] bootindex: move calling add_boot_device_patch to bootindex setter function, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 27/34] block: remove bootindex property from qdev to qom, arei.gonglei, 2014/10/07
- Re: [Qemu-devel] [PATCH v11 00/34] modify boot order of guest, and take effect after rebooting, Gonglei, 2014/10/08
- Re: [Qemu-devel] [PATCH v11 00/34] modify boot order of guest, and take effect after rebooting, Paolo Bonzini, 2014/10/09