[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 43/55] qdev: Introduce PropertyInfo.create
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 43/55] qdev: Introduce PropertyInfo.create |
Date: |
Fri, 14 Jul 2017 12:10:16 +0200 |
From: Fam Zheng <address@hidden>
This allows property implementation to provide a specialized property
creation method.
Update conditions guarding property types accordingly.
Signed-off-by: Fam Zheng <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/core/qdev.c | 31 +++++++++++++++++++------------
include/hw/qdev-core.h | 1 +
qmp.c | 2 +-
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 849952a..ec63fe0 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -744,6 +744,10 @@ static void qdev_property_add_legacy(DeviceState *dev,
Property *prop,
return;
}
+ if (prop->info->create) {
+ return;
+ }
+
name = g_strdup_printf("legacy-%s", prop->name);
object_property_add(OBJECT(dev), name, "str",
prop->info->print ? qdev_get_legacy_property :
prop->info->get,
@@ -770,20 +774,23 @@ void qdev_property_add_static(DeviceState *dev, Property
*prop,
Error *local_err = NULL;
Object *obj = OBJECT(dev);
- /*
- * TODO qdev_prop_ptr does not have getters or setters. It must
- * go now that it can be replaced with links. The test should be
- * removed along with it: all static properties are read/write.
- */
- if (!prop->info->get && !prop->info->set) {
- return;
+ if (prop->info->create) {
+ prop->info->create(obj, prop, &local_err);
+ } else {
+ /*
+ * TODO qdev_prop_ptr does not have getters or setters. It must
+ * go now that it can be replaced with links. The test should be
+ * removed along with it: all static properties are read/write.
+ */
+ if (!prop->info->get && !prop->info->set) {
+ return;
+ }
+ object_property_add(obj, prop->name, prop->info->name,
+ prop->info->get, prop->info->set,
+ prop->info->release,
+ prop, &local_err);
}
- object_property_add(obj, prop->name, prop->info->name,
- prop->info->get, prop->info->set,
- prop->info->release,
- prop, &local_err);
-
if (local_err) {
error_propagate(errp, local_err);
return;
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 9d7c1c0..33518ee 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -241,6 +241,7 @@ struct PropertyInfo {
const char * const *enum_table;
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
void (*set_default_value)(Object *obj, const Property *prop);
+ void (*create)(Object *obj, Property *prop, Error **errp);
ObjectPropertyAccessor *get;
ObjectPropertyAccessor *set;
ObjectPropertyRelease *release;
diff --git a/qmp.c b/qmp.c
index 84a4f29..e6b68fe 100644
--- a/qmp.c
+++ b/qmp.c
@@ -480,7 +480,7 @@ static DevicePropertyInfo
*make_device_property_info(ObjectClass *klass,
* for removal. This conditional should be removed along with
* it.
*/
- if (!prop->info->set) {
+ if (!prop->info->set && !prop->info->create) {
return NULL; /* no way to set it, don't show */
}
--
1.8.3.1
- [Qemu-devel] [PULL v2 00/55] Misc patches for QEMU 2.10 soft freeze, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 22/55] Revert "exec.c: Fix breakpoint invalidation race", Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 43/55] qdev: Introduce PropertyInfo.create,
Paolo Bonzini <=
- [Qemu-devel] [PULL 42/55] qom: enforce readonly nature of link's check callback, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 45/55] qmp: Use ObjectProperty.type if present, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 44/55] qdev: Introduce DEFINE_PROP_LINK, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 23/55] mttcg/i386: Patch instruction using async_safe_* framework, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 46/55] qdev: Add const qualifier to PropertyInfo definitions, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 47/55] virtio-blk: Convert to DEFINE_PROP_LINK, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 49/55] virtio-rng: Convert to DEFINE_PROP_LINK, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 51/55] dimm: Convert to DEFINE_PROP_LINK, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 48/55] virtio-scsi: Convert to DEFINE_PROP_LINK, Paolo Bonzini, 2017/07/14
- [Qemu-devel] [PULL 50/55] virtio-crypto: Convert to DEFINE_PROP_LINK, Paolo Bonzini, 2017/07/14