From 5879bb85f2fb6a8049c4a17fe8cc5725e05e7449 Mon Sep 17 00:00:00 2001 From: Nobuhiro MIKI Date: Sun, 21 Feb 2021 00:27:13 +0900 Subject: [PATCH] machine: handle return code EINTR for ioctl KVM_RUN Signed-off-by: Nobuhiro MIKI --- kvm/kvm.go | 3 ++- machine/machine.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kvm/kvm.go b/kvm/kvm.go index a63dbcf..6679151 100644 --- a/kvm/kvm.go +++ b/kvm/kvm.go @@ -120,7 +120,8 @@ type Descriptor struct { type RunData struct { RequestInterruptWindow uint8 - _ [7]uint8 + ImmediateExit uint8 + _ [6]uint8 ExitReason uint32 ReadyForInterruptInjection uint8 IfFlag uint8 diff --git a/machine/machine.go b/machine/machine.go index bd6d2f2..32bdf49 100644 --- a/machine/machine.go +++ b/machine/machine.go @@ -293,6 +293,12 @@ func (m *Machine) RunInfiniteLoop() error { func (m *Machine) RunOnce() (bool, error) { if err := kvm.Run(m.vcpuFd); err != nil { + // When a signal is sent to the thread hosting the VM it will result in EINTR + // refs https://gist.github.com/mcastelino/df7e65ade874f6890f618dc51778d83a + if m.run.ExitReason == kvm.EXITINTR { + return true, nil + } + return false, err }