From 823efc5d26671e4737b2951d65b0565806ee43ab Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 15 Jun 2016 14:59:46 -0300 Subject: qdev: Don't stop applying globals on first error qdev_prop_set_globals_for_type() stops applying global properties on the first error. It is a leftover from when QEMU exited on any error when applying global property. Commit 25f8dd9 changed the fatal error to a warning, but neglected to drop the stopping. Fix that. For example, the following command-line will not set CPUID level to 3, but will warn only about "x86_64-cpu.vendor" being ignored. $ ./x86_64-softmmu/qemu-system-x86_64 \ -global x86_64-cpu.vendor=x \ -global x86_64-cpu.level=3 qemu-system-x86_64: Warning: global x86_64-cpu.vendor=x ignored: Property '.vendor' doesn't take value 'x' Fix this by not returning from qdev_prop_set_globals_for_type() on the first error. Cc: Markus Armbruster Reviewed-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost --- hw/core/qdev-properties.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw/core/qdev-properties.c') diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index e3b2184a60..c10edeecf1 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1088,7 +1088,6 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev, assert(prop->user_provided); error_reportf_err(err, "Warning: global %s.%s=%s ignored: ", prop->driver, prop->property, prop->value); - return; } } } -- cgit 1.4.1 From 77280adbdf308af855844d921e5f16a873840568 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 15 Jun 2016 16:08:06 -0300 Subject: qdev: GlobalProperty.errp field The new field will allow error handling to be configured by qdev_prop_register_global() callers: &error_fatal and &error_abort can be used to make QEMU exit or abort if any errors are reported when applying the properties. While doing it, change the error message from "global %s.%s=%s ignored" to "can't apply global %s.%s=%s". Suggested-by: Paolo Bonzini Reviewed-by: Igor Mammedov Reviewed-by: Markus Armbruster Signed-off-by: Eduardo Habkost --- hw/core/qdev-properties.c | 11 ++++++++--- include/hw/qdev-core.h | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'hw/core/qdev-properties.c') diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index c10edeecf1..3c20c8e4b2 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1085,9 +1085,14 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev, prop->used = true; object_property_parse(OBJECT(dev), prop->value, prop->property, &err); if (err != NULL) { - assert(prop->user_provided); - error_reportf_err(err, "Warning: global %s.%s=%s ignored: ", - prop->driver, prop->property, prop->value); + error_prepend(&err, "can't apply global %s.%s=%s: ", + prop->driver, prop->property, prop->value); + if (prop->errp) { + error_propagate(prop->errp, err); + } else { + assert(prop->user_provided); + error_reportf_err(err, "Warning: "); + } } } } diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 24aa0a7949..1d1f8612a9 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -259,6 +259,9 @@ struct PropertyInfo { * @user_provided: Set to true if property comes from user-provided config * (command-line or config file). * @used: Set to true if property was used when initializing a device. + * @errp: Error destination, used like first argument of error_setg() + * in case property setting fails later. If @errp is NULL, we + * print warnings instead of ignoring errors silently. */ typedef struct GlobalProperty { const char *driver; @@ -266,6 +269,7 @@ typedef struct GlobalProperty { const char *value; bool user_provided; bool used; + Error **errp; } GlobalProperty; /*** Board API. This should go away once we have a machine config file. ***/ -- cgit 1.4.1