summaryrefslogtreecommitdiffstats
path: root/hw/core
diff options
context:
space:
mode:
authorEduardo Habkost2020-12-11 23:05:22 +0100
committerEduardo Habkost2020-12-18 21:20:17 +0100
commit0d5d5bc58b3b1af3b25411642537464bac1d0583 (patch)
tree9293b500dcfeb6483a38c8ea9cdab2ff1e92da60 /hw/core
parentqdev: Make PropertyInfo.create return ObjectProperty* (diff)
downloadqemu-0d5d5bc58b3b1af3b25411642537464bac1d0583.tar.gz
qemu-0d5d5bc58b3b1af3b25411642537464bac1d0583.tar.xz
qemu-0d5d5bc58b3b1af3b25411642537464bac1d0583.zip
qdev: Make qdev_class_add_property() more flexible
Support Property.set_default and PropertyInfo.description even if PropertyInfo.create is set. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20201211220529.2290218-26-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/qdev-properties.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 3bb05e7d0d..2946cdf56d 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -863,24 +863,22 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name,
Property *prop)
{
ObjectClass *oc = OBJECT_CLASS(klass);
+ ObjectProperty *op;
if (prop->info->create) {
- prop->info->create(oc, name, prop);
+ op = prop->info->create(oc, name, prop);
} else {
- ObjectProperty *op;
-
op = object_class_property_add(oc,
name, prop->info->name,
field_prop_getter(prop->info),
field_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, name,
- prop->info->description);
+ if (prop->set_default) {
+ prop->info->set_default_value(op, prop);
+ }
+ object_class_property_set_description(oc, name, prop->info->description);
}
/**