[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/7] accel/kvm: Exit gracefully when KVM is not supported
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 7/7] accel/kvm: Exit gracefully when KVM is not supported |
Date: |
Fri, 19 Feb 2021 12:44:28 +0100 |
Now that we added the 'kvm_supported' field to MachineClass
and all our machines able to use KVM have this field set,
we can check it in kvm_init() and exit gracefully with
a friendly error message.
Before:
$ qemu-system-aarch64 -M raspi3b -enable-kvm
qemu-system-aarch64: /build/qemu-ETIdrs/qemu-4.2/exec.c:865:
cpu_address_space_init: Assertion `asidx == 0 || !kvm_enabled()' failed.
Aborted
$ qemu-system-aarch64 -M xlnx-zcu102 -enable-kvm -smp 6
qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid
argument
After:
$ qemu-system-aarch64 -M raspi3b -enable-kvm
Machine 'raspi3b' does not support KVM
$ qemu-system-aarch64 -M xlnx-zcu102 -enable-kvm -smp 6
Machine 'xlnx-zcu102' does not support KVM
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
accel/kvm/kvm-all.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index b069938d881..8a8d3f64248 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2001,6 +2001,12 @@ static int kvm_init(MachineState *ms)
s = KVM_STATE(ms->accelerator);
+ if (!mc->kvm_supported) {
+ ret = -EINVAL;
+ fprintf(stderr, "Machine '%s' does not support KVM\n", mc->name);
+ exit(1);
+ }
+
/*
* On systems where the kernel can support different base page
* sizes, host page size may be different from TARGET_PAGE_SIZE,
--
2.26.2
- [PATCH 1/7] accel/kvm: Check MachineClass kvm_type() return value, (continued)
- [PATCH 3/7] hw/arm: Set kvm_supported for KVM-compatible machines, Philippe Mathieu-Daudé, 2021/02/19
- [PATCH 4/7] hw/mips: Set kvm_supported for KVM-compatible machines, Philippe Mathieu-Daudé, 2021/02/19
- [RFC PATCH 5/7] hw/ppc: Set kvm_supported for KVM-compatible machines, Philippe Mathieu-Daudé, 2021/02/19
- [PATCH 6/7] hw/s390x: Set kvm_supported to s390-ccw-virtio machines, Philippe Mathieu-Daudé, 2021/02/19
- [PATCH 7/7] accel/kvm: Exit gracefully when KVM is not supported,
Philippe Mathieu-Daudé <=
- Re: [PATCH 0/7] hw/kvm: Exit gracefully when KVM is not supported, Peter Maydell, 2021/02/19
- Re: [PATCH 0/7] hw/kvm: Exit gracefully when KVM is not supported, Daniel P . Berrangé, 2021/02/19
Re: [PATCH 0/7] hw/kvm: Exit gracefully when KVM is not supported, Claudio Fontana, 2021/02/19