[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 16/36] qdev: Make qdev_class_add_property() more flexible
From: |
Eduardo Habkost |
Subject: |
[PATCH 16/36] qdev: Make qdev_class_add_property() more flexible |
Date: |
Thu, 29 Oct 2020 18:02:26 -0400 |
Support Property.set_default and PropertyInfo.description even if
PropertyInfo.create is set.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
hw/core/qdev-properties.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 89e292dc25..ad685f371d 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -912,24 +912,25 @@ void qdev_property_add_static(DeviceState *dev, Property
*prop)
static void qdev_class_add_property(DeviceClass *klass, Property *prop)
{
ObjectClass *oc = OBJECT_CLASS(klass);
+ ObjectProperty *op;
if (prop->info->create) {
- prop->info->create(oc, prop);
+ op = prop->info->create(oc, prop);
} else {
- ObjectProperty *op;
-
op = object_class_property_add(oc,
prop->name, prop->info->name,
static_prop_getter(prop->info),
static_prop_setter(prop->info),
prop->info->release,
prop);
- if (prop->set_default) {
- prop->info->set_default_value(op, prop);
- }
}
- object_class_property_set_description(oc, prop->name,
- prop->info->description);
+ if (prop->set_default) {
+ prop->info->set_default_value(op, prop);
+ }
+ if (prop->info->description) {
+ object_class_property_set_description(oc, prop->name,
+ prop->info->description);
+ }
}
/**
--
2.28.0
- --enable-xen on gitlab CI? (was Re: [PATCH 09/36] qdev: Make qdev_get_prop_ptr() get Object* arg), (continued)
- [PATCH 11/36] qdev: Make check_prop_still_unset() get Object* argument, Eduardo Habkost, 2020/10/29
- [PATCH 13/36] qdev: Wrap getters and setters in separate helpers, Eduardo Habkost, 2020/10/29
- [PATCH 12/36] qdev: Make error_set_from_qdev_prop_error() get Object* argument, Eduardo Habkost, 2020/10/29
- [PATCH 15/36] qdev: Make PropertyInfo.create return ObjectProperty*, Eduardo Habkost, 2020/10/29
- [PATCH 16/36] qdev: Make qdev_class_add_property() more flexible,
Eduardo Habkost <=
- [PATCH 17/36] qdev: Separate generic and device-specific property registration, Eduardo Habkost, 2020/10/29
- [PATCH 19/36] qdev: Move array property creation/registration to separate functions, Eduardo Habkost, 2020/10/29
- [PATCH 20/36] qdev: Reuse object_property_add_static() when adding array elements, Eduardo Habkost, 2020/10/29