mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
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>
This commit is contained in:
parent
d828c430eb
commit
b3ce84fea4
4 changed files with 83 additions and 39 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue