]> git.proxmox.com Git - mirror_qemu.git/commit
spapr.c: set a 'kvm-type' default value instead of relying on NULL
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Thu, 10 Dec 2020 14:55:17 +0000 (11:55 -0300)
committerDavid Gibson <david@gibson.dropbear.id.au>
Mon, 14 Dec 2020 04:54:12 +0000 (15:54 +1100)
commit07b10bc42cc83a49acaa783383a69fb59d7ff71a
tree70f8b9ef69dcc4de30e33541616367817dc36132
parent0ff6b52094a7aa0cd5e989624d77e206e904916c
spapr.c: set a 'kvm-type' default value instead of relying on NULL

spapr_kvm_type() is considering 'vm_type=NULL' as a valid input, where
the function returns 0. This is relying on the current QEMU machine
options handling logic, where the absence of the 'kvm-type' option
will be reflected as 'vm_type=NULL' in this function.

This is not robust, and will break if QEMU options code decides to propagate
something else in the case mentioned above (e.g. an empty string instead
of NULL).

Let's avoid this entirely by setting a non-NULL default value in case of
no user input for 'kvm-type'. spapr_kvm_type() was changed to handle 3 fixed
values of kvm-type: "auto", "hv", and "pr", with "auto" being the default
if no kvm-type was set by the user. This allows us to always be predictable
regardless of any enhancements/changes made in QEMU options mechanics.

While we're at it, let's also document in 'kvm-type' description the
already existing default mode, now named 'auto'. The information provided
about it is based on how the pseries kernel handles the KVM_CREATE_VM
ioctl(), where the default value '0' makes the kernel choose an available
KVM module to use, giving precedence to kvm_hv. This logic is described in
the kernel source file arch/powerpc/kvm/powerpc.c, function kvm_arch_init_vm().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20201210145517.1532269-2-danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
hw/ppc/spapr.c