From 62ccccc303ac08177521ca0a5922a49ef0622504 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 5 Feb 2020 09:35:56 +0100 Subject: [PATCH] vmm: Make sure to retry creating the VM on EINTR If the ioctl syscall KVM_CREATE_VM gets interrupted while creating the VM, it is expected that we should retry since EINTR should not be considered a standard error. Signed-off-by: Sebastien Boeuf --- vmm/src/vm.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 440cb7586..c23f52743 100755 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -241,7 +241,24 @@ impl Vm { let kernel = File::open(&config.lock().unwrap().kernel.as_ref().unwrap().path) .map_err(Error::KernelFile)?; - let fd = kvm.create_vm().map_err(Error::VmCreate)?; + + let fd: VmFd; + loop { + match kvm.create_vm() { + Ok(res) => fd = res, + Err(e) => { + if e.errno() == libc::EINTR { + // If the error returned is EINTR, which means the + // ioctl has been interrupted, we have to retry as + // this can't be considered as a regular error. + continue; + } else { + return Err(Error::VmCreate(e)); + } + } + } + break; + } let fd = Arc::new(fd); // Set TSS