aboutsummaryrefslogtreecommitdiff
path: root/hw/core/qdev-properties.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/core/qdev-properties.c')
-rw-r--r--hw/core/qdev-properties.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ca1739ec84..3a324fb0c3 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -986,25 +986,18 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
}
}
-int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
+void qdev_prop_parse(DeviceState *dev, const char *name, const char *value,
+ Error **errp)
{
char *legacy_name;
- Error *err = NULL;
legacy_name = g_strdup_printf("legacy-%s", name);
if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
- object_property_parse(OBJECT(dev), value, legacy_name, &err);
+ object_property_parse(OBJECT(dev), value, legacy_name, errp);
} else {
- object_property_parse(OBJECT(dev), value, name, &err);
+ object_property_parse(OBJECT(dev), value, name, errp);
}
g_free(legacy_name);
-
- if (err) {
- qerror_report_err(err);
- error_free(err);
- return -1;
- }
- return 0;
}
void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value)
@@ -1106,19 +1099,37 @@ void qdev_prop_register_global_list(GlobalProperty *props)
}
}
-void qdev_prop_set_globals(DeviceState *dev)
+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)
{
ObjectClass *class = object_get_class(OBJECT(dev));
do {
- GlobalProperty *prop;
- QTAILQ_FOREACH(prop, &global_props, next) {
- if (strcmp(object_class_get_name(class), prop->driver) != 0) {
- continue;
- }
- if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
- exit(1);
- }
+ Error *err = NULL;
+
+ qdev_prop_set_globals_for_type(dev, object_class_get_name(class),
+ &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
}
class = object_class_get_parent(class);
} while (class);