@@ -127,7 +127,8 @@ typedef struct {
* implement and a stub device is required.
* @kvm_type:
* Return the type of KVM corresponding to the kvm-type string option or
- * computed based on other criteria such as the host kernel capabilities.
+ * computed based on other criteria such as the host kernel capabilities
+ * (which can't be negative), or -1 on error.
* @numa_mem_supported:
* true if '--numa node.mem' option is supported and false otherwise
* @smp_parse:
@@ -2057,6 +2057,12 @@ static int kvm_init(MachineState *ms)
"kvm-type",
&error_abort);
type = mc->kvm_type(ms, kvm_type);
+ if (type < 0) {
+ ret = -EINVAL;
+ fprintf(stderr, "Failed to detect kvm-type for machine '%s'\n",
+ mc->name);
+ goto err;
+ }
}
do {
MachineClass::kvm_type() can return -1 on failure. Document it, and add a check in kvm_init(). Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- include/hw/boards.h | 3 ++- accel/kvm/kvm-all.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-)