diff options
author | Eduardo Habkost | 2014-08-08 21:03:31 +0200 |
---|---|---|
committer | Michael S. Tsirkin | 2014-09-18 20:51:24 +0200 |
commit | b3ce84fea466f3bca2ff85d158744f00c0f429bd (patch) | |
tree | ac624099ecb8667083bda728ee89f451d923bc49 /hw/core/qdev-properties.c | |
parent | qdev: Rename qdev_prop_check_global() to qdev_prop_check_globals() (diff) | |
download | qemu-b3ce84fea466f3bca2ff85d158744f00c0f429bd.tar.gz qemu-b3ce84fea466f3bca2ff85d158744f00c0f429bd.tar.xz qemu-b3ce84fea466f3bca2ff85d158744f00c0f429bd.zip |
qdev: Move global validation to a single function
Currently GlobalProperty.not_used=false has multiple meanings:
* It may be a property for a hotpluggable device, which may or may not
have been used by a device;
* It may be a machine-type-provided property, which may or may not have
been used by a device.
* It may be a user-provided property that was actually not used by
any device.
Simplify the logic by having two separate fields: 'user_provided' and
'used'. This allows the entire global property validation logic to be
contained in a single function, and allows more specific error messages.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/core/qdev-properties.c')
-rw-r--r-- | hw/core/qdev-properties.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 9075453f2d..66556d3bf9 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -961,13 +961,29 @@ int qdev_prop_check_globals(void) int ret = 0; QTAILQ_FOREACH(prop, &global_props, next) { - if (!prop->not_used) { + ObjectClass *oc; + DeviceClass *dc; + if (prop->used) { + continue; + } + if (!prop->user_provided) { + continue; + } + oc = object_class_by_name(prop->driver); + oc = object_class_dynamic_cast(oc, TYPE_DEVICE); + if (!oc) { + error_report("Warning: global %s.%s has invalid class name", + prop->driver, prop->property); + ret = 1; + continue; + } + dc = DEVICE_CLASS(oc); + if (!dc->hotpluggable && !prop->used) { + error_report("Warning: global %s.%s=%s not used", + prop->driver, prop->property, prop->value); + ret = 1; continue; } - ret = 1; - error_report("Warning: \"-global %s.%s=%s\" not used", - prop->driver, prop->property, prop->value); - } return ret; } @@ -983,7 +999,7 @@ void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename, if (strcmp(typename, prop->driver) != 0) { continue; } - prop->not_used = false; + prop->used = true; object_property_parse(OBJECT(dev), prop->value, prop->property, &err); if (err != NULL) { error_propagate(errp, err); |