kvm: Explicitly provide an argument to KVM_CREATE_VM

On all architectures, KVM_CREATE_VM takes an argument known
as the 'machine type identifier'. This machine type is
architecture dependent, and the documentation helpfully says:

	You probably want to use 0 as machine type.

So let's do that.

Change-Id: I8a8a0f7b78e32012c5ab841097c05a02fe0532ff
Signed-off-by: Marc Zyngier <mzyngier@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3124676
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Marc Zyngier 2021-08-26 15:10:43 +01:00 committed by Commit Bot
parent 731f0809a3
commit 7af8b6f879
2 changed files with 2 additions and 2 deletions

View file

@ -166,7 +166,7 @@ impl KvmVm {
pub fn new(kvm: &Kvm, guest_mem: GuestMemory) -> Result<KvmVm> {
// Safe because we know kvm is a real kvm fd as this module is the only one that can make
// Kvm objects.
let ret = unsafe { ioctl(kvm, KVM_CREATE_VM()) };
let ret = unsafe { ioctl_with_val(kvm, KVM_CREATE_VM(), 0) };
if ret < 0 {
return errno_result();
}

View file

@ -274,7 +274,7 @@ impl Vm {
pub fn new(kvm: &Kvm, guest_mem: GuestMemory) -> Result<Vm> {
// Safe because we know kvm is a real kvm fd as this module is the only one that can make
// Kvm objects.
let ret = unsafe { ioctl(kvm, KVM_CREATE_VM()) };
let ret = unsafe { ioctl_with_val(kvm, KVM_CREATE_VM(), 0) };
if ret >= 0 {
// Safe because we verify the value of ret and we are the owners of the fd.
let vm_file = unsafe { File::from_raw_descriptor(ret) };