]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
accel/kvm: Use negative KVM type for error propagation
authorAkihiko Odaki <akihiko.odaki@daynix.com>
Tue, 22 Aug 2023 16:31:03 +0000 (17:31 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 22 Aug 2023 16:31:03 +0000 (17:31 +0100)
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 <akihiko.odaki@daynix.com>
Message-id: 20230727073134.134102-5-akihiko.odaki@daynix.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
accel/kvm/kvm-all.c
hw/arm/virt.c
hw/ppc/spapr.c

index b4723016379fffe6f8f29e1566dfabee343cb437..3bac5aa678b3d4111de484bcdc78f2a794d160dd 100644 (file)
@@ -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);
index 7d9dbc26633a86fbf58d463372eb7cea120f66f4..83c05f1b9f61c2bb15532662944e68254308666b 100644 (file)
@@ -2913,7 +2913,7 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
                      "require an IPA range (%d bits) larger than "
                      "the one supported by the host (%d bits)",
                      requested_pa_size, max_vm_pa_size);
-        exit(1);
+        return -1;
     }
     /*
      * We return the requested PA log size, unless KVM only supports
index 1c8b8d57a70aa2e4279ef5ab9dd3900de500a17c..e851f609198a5b1cad53933926cd3306155e9862 100644 (file)
@@ -3105,7 +3105,7 @@ static int spapr_kvm_type(MachineState *machine, const char *vm_type)
     }
 
     error_report("Unknown kvm-type specified '%s'", vm_type);
-    exit(1);
+    return -1;
 }
 
 /*