qdev: Introduce qdev_prop_set_globals_for_type()

Reuse it in qdev_prop_set_globals().

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
[AF: Renamed from qdev_prop_set_custom_globals()]
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Andreas Färber 2013-05-01 16:03:19 +02:00
parent b1fe9bcbce
commit 868d378bb0
2 changed files with 27 additions and 11 deletions

View File

@ -1099,23 +1099,37 @@ void qdev_prop_register_global_list(GlobalProperty *props)
} }
} }
void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
Error **errp)
{
GlobalProperty *prop;
QTAILQ_FOREACH(prop, &global_props, next) {
Error *err = NULL;
if (strcmp(typename, prop->driver) != 0) {
continue;
}
qdev_prop_parse(dev, prop->property, prop->value, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
}
}
void qdev_prop_set_globals(DeviceState *dev, Error **errp) void qdev_prop_set_globals(DeviceState *dev, Error **errp)
{ {
ObjectClass *class = object_get_class(OBJECT(dev)); ObjectClass *class = object_get_class(OBJECT(dev));
do { do {
GlobalProperty *prop; Error *err = NULL;
QTAILQ_FOREACH(prop, &global_props, next) {
Error *err = NULL;
if (strcmp(object_class_get_name(class), prop->driver) != 0) { qdev_prop_set_globals_for_type(dev, object_class_get_name(class),
continue; &err);
} if (err != NULL) {
qdev_prop_parse(dev, prop->property, prop->value, &err); error_propagate(errp, err);
if (err != NULL) { return;
error_propagate(errp, err);
return;
}
} }
class = object_class_get_parent(class); class = object_class_get_parent(class);
} while (class); } while (class);

View File

@ -169,6 +169,8 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
void qdev_prop_register_global(GlobalProperty *prop); void qdev_prop_register_global(GlobalProperty *prop);
void qdev_prop_register_global_list(GlobalProperty *props); void qdev_prop_register_global_list(GlobalProperty *props);
void qdev_prop_set_globals(DeviceState *dev, Error **errp); void qdev_prop_set_globals(DeviceState *dev, Error **errp);
void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
Error **errp);
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
Property *prop, const char *value); Property *prop, const char *value);