From bc3e41a0e8a3c932733dd363dfcfb38bf167b707 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 22 Aug 2023 17:31:03 +0100 Subject: accel/kvm: Use negative KVM type for error propagation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On MIPS, kvm_arch_get_default_type() returns a negative value when an error occurred so handle the case. Also, let other machines return negative values when errors occur and declare returning a negative value as the correct way to propagate an error that happened when determining KVM type. Signed-off-by: Akihiko Odaki Message-id: 20230727073134.134102-5-akihiko.odaki@daynix.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- accel/kvm/kvm-all.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'accel') diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b472301637..3bac5aa678 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2527,6 +2527,11 @@ static int kvm_init(MachineState *ms) type = kvm_arch_get_default_type(ms); } + if (type < 0) { + ret = -EINVAL; + goto err; + } + do { ret = kvm_ioctl(s, KVM_CREATE_VM, type); } while (ret == -EINTR); -- cgit v1.2.3