[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/2] qom/object, accel-system: add support to Accel globals
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v2 2/2] qom/object, accel-system: add support to Accel globals |
Date: |
Wed, 3 Jul 2024 17:41:49 -0300 |
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 object_prop_set_globals() in
accel_init_machine(). As done in device_post_init(), user's global
props take precedence over compat props so object_prop_set_globals() is
called after object_set_accelerator_compat_props().
object_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]
20240701133038.1489043-1-dbarboza@ventanamicro.com/">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 | 2 ++
qom/object.c | 34 +++++++++++++++++++++++-----------
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/accel/accel-system.c b/accel/accel-system.c
index f6c947dd82..8cb1eaa907 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -29,6 +29,7 @@
#include "sysemu/cpus.h"
#include "qemu/error-report.h"
#include "accel-system.h"
+#include "qapi/error.h"
int accel_init_machine(AccelState *accel, MachineState *ms)
{
@@ -43,6 +44,7 @@ int accel_init_machine(AccelState *accel, MachineState *ms)
object_unref(OBJECT(accel));
} else {
object_set_accelerator_compat_props(acc->compat_props);
+ object_prop_set_globals(OBJECT(accel), &error_fatal);
}
return ret;
}
diff --git a/qom/object.c b/qom/object.c
index 60dbd00edd..8730e770e6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -15,6 +15,7 @@
#include "qapi/error.h"
#include "qom/object.h"
#include "qom/object_interfaces.h"
+#include "qemu/accel.h"
#include "qemu/cutils.h"
#include "qemu/memalign.h"
#include "qapi/visitor.h"
@@ -516,27 +517,38 @@ int object_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;
--
2.45.2