diff options
author | Fam Zheng <famz@redhat.com> | 2017-07-14 10:14:51 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-07-14 12:04:42 +0200 |
commit | faabdbb792889bf011a593578d1de51e14616bb7 (patch) | |
tree | 463f083cf9cb60b20bd76b5acc609a0b3576cf57 /hw/core | |
parent | 8f5d58ef2c92d7b82d9a6eeefd7c8854a183ba4a (diff) |
qdev: Introduce PropertyInfo.create
This allows property implementation to provide a specialized property
creation method.
Update conditions guarding property types accordingly.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170714021509.23681-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/qdev.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 849952a8d4..ec63fe0354 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; |