summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2020-01-23 11:47:30 -0800
committergVisor bot <gvisor-bot@google.com>2020-01-23 11:49:02 -0800
commit7a79715504e92be9fc9aebc12fbd65aa46049054 (patch)
treead669c27eb7200dd48b58aaf312f935cce9747a6 /pkg
parent98e83c444fa58669d45ecf162cf4bf48dce790d1 (diff)
Check for EINTR from KVM_CREATE_VM
The kernel may return EINTR from: kvm_create_vm kvm_init_mmu_notifier mmu_notifier_register do_mmu_notifier_register mm_take_all_locks Go 1.14's preemptive scheduling signals make hitting this much more likely. PiperOrigin-RevId: 291212669
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/platform/kvm/kvm.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/pkg/sentry/platform/kvm/kvm.go b/pkg/sentry/platform/kvm/kvm.go
index a7850faed..d337c5c7c 100644
--- a/pkg/sentry/platform/kvm/kvm.go
+++ b/pkg/sentry/platform/kvm/kvm.go
@@ -62,9 +62,19 @@ func New(deviceFile *os.File) (*KVM, error) {
}
// Create a new VM fd.
- vm, _, errno := syscall.RawSyscall(syscall.SYS_IOCTL, fd, _KVM_CREATE_VM, 0)
- if errno != 0 {
- return nil, fmt.Errorf("creating VM: %v", errno)
+ var (
+ vm uintptr
+ errno syscall.Errno
+ )
+ for {
+ vm, _, errno = syscall.Syscall(syscall.SYS_IOCTL, fd, _KVM_CREATE_VM, 0)
+ if errno == syscall.EINTR {
+ continue
+ }
+ if errno != 0 {
+ return nil, fmt.Errorf("creating VM: %v", errno)
+ }
+ break
}
// We are done with the device file.
deviceFile.Close()