On 10/3/25 13:54, BALATON Zoltan wrote:
On Mon, 10 Mar 2025, Eric Auger wrote:
Hi Philippe,
On 3/9/25 12:09 AM, Philippe Mathieu-Daudé wrote:
Use the runtime kvm_enabled() helper to check whether
KVM is available or not.
Miss the "why" of this patch.
By the way I fail to remember/see where kvm_allowed is set.
In accel/accel-system.c:
int accel_init_machine(AccelState *accel, MachineState *ms)
{
AccelClass *acc = ACCEL_GET_CLASS(accel);
int ret;
ms->accelerator = accel;
*(acc->allowed) = true;
ret = acc->init_machine(ms);
if (ret < 0) {
ms->accelerator = NULL;
*(acc->allowed) = false;
object_unref(OBJECT(accel));
} else {
object_set_accelerator_compat_props(acc->compat_props);
}
return ret;
}
It's in include/system/kvm.h
I am also confused because we still have some code, like in
vfio/common.c which does both checks:
#ifdef CONFIG_KVM
if (kvm_enabled()) {
max_memslots = kvm_get_max_memslots();
}
#endif
We should prefer kvm_enabled() over CONFIG_KVM, but for kvm_enabled()
we need the prototypes declared, which sometimes aren't.