@@ -29,6 +29,8 @@
#include "sysemu/cpus.h"
#include "qemu/error-report.h"
#include "accel-system.h"
+#include "qapi/error.h"
+#include "hw/qdev-properties.h"
int accel_init_machine(AccelState *accel, MachineState *ms)
{
@@ -43,6 +45,7 @@ int accel_init_machine(AccelState *accel, MachineState *ms)
object_unref(OBJECT(accel));
} else {
object_set_accelerator_compat_props(acc->compat_props);
+ qdev_prop_set_globals(OBJECT(accel), &error_fatal);
}
return ret;
}
@@ -10,6 +10,7 @@
#include "qemu/cutils.h"
#include "qdev-prop-internal.h"
#include "qom/qom-qobject.h"
+#include "qemu/accel.h"
void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
Error **errp)
@@ -894,27 +895,38 @@ int qdev_prop_check_globals(void)
for (i = 0; i < global_props()->len; i++) {
GlobalProperty *prop;
- ObjectClass *oc;
+ ObjectClass *globalc, *oc;
DeviceClass *dc;
prop = g_ptr_array_index(global_props(), i);
if (prop->used) {
continue;
}
- oc = object_class_by_name(prop->driver);
- oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
- if (!oc) {
- warn_report("global %s.%s has invalid class name",
- prop->driver, prop->property);
- ret = 1;
+ globalc = object_class_by_name(prop->driver);
+ oc = object_class_dynamic_cast(globalc, TYPE_DEVICE);
+ if (oc) {
+ dc = DEVICE_CLASS(oc);
+ if (!dc->hotpluggable && !prop->used) {
+ warn_report("global %s.%s=%s not used",
+ prop->driver, prop->property, prop->value);
+ ret = 1;
+ }
continue;
}
- dc = DEVICE_CLASS(oc);
- if (!dc->hotpluggable && !prop->used) {
+
+ /*
+ * At this point is either an accelerator global that is
+ * unused or an invalid global. Both set ret = 1.
+ */
+ ret = 1;
+
+ oc = object_class_dynamic_cast(globalc, TYPE_ACCEL);
+ if (oc) {
warn_report("global %s.%s=%s not used",
prop->driver, prop->property, prop->value);
- ret = 1;
- continue;
+ } else {
+ warn_report("global %s.%s has invalid class name",
+ prop->driver, prop->property);
}
}
return ret;
We're not honouring KVM options that are provided by any -accel option aside from the first. In this example: qemu-system-riscv64 -accel kvm,riscv-aia=emul (...) \ -accel kvm,riscv-aia=hwaccel 'riscv-aia' will be set to 'emul', ignoring the last occurrence of the option that set 'riscv-aia' to 'hwaccel'. A failed attempt to solve this issue by setting 'merge_lists' can be found in [1]. A different approach was suggested in [2]: enable global properties for accelerators. This allows an user to override any accel setting by using '-global' and we won't need to change how '-accel' opts are handled. This is done by calling qdev_prop_set_globals() in accel_init_machine(). As done in device_post_init(), user's global props take precedence over compat props so qdev_prop_set_globals() is called after object_set_accelerator_compat_props(). qdev_prop_check_globals() is then changed to recognize TYPE_ACCEL globals as valid. Re-using the fore-mentioned example we'll be able to set riscv-aia=hwaccel by doing the following: qemu-system-riscv64 -accel kvm,riscv-aia=emul (...) \ -global kvm-accel.riscv-aia=hwaccel [1] https://lore.kernel.org/qemu-devel/20240701133038.1489043-1-dbarboza@ventanamicro.com/ [2] https://lore.kernel.org/qemu-devel/CABgObfbVJkCdpHV2uA7LGTbYEaoaizrbeG0vNo_T1ua5b=jq7Q@mail.gmail.com/ Reported-by: Andrew Jones <ajones@ventanamicro.com> Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> --- accel/accel-system.c | 3 +++ hw/core/qdev-properties.c | 34 +++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-)