Skip to content

Commit

Permalink
Merge pull request #20 from nmi/handle_eintr_kvm_run
Browse files Browse the repository at this point in the history
machine: handle return code EINTR for ioctl KVM_RUN
  • Loading branch information
bobuhiro11 authored Feb 21, 2021
2 parents 194b575 + 5879bb8 commit d6540da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kvm/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ type Descriptor struct {

type RunData struct {
RequestInterruptWindow uint8
_ [7]uint8
ImmediateExit uint8
_ [6]uint8
ExitReason uint32
ReadyForInterruptInjection uint8
IfFlag uint8
Expand Down
6 changes: 6 additions & 0 deletions machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit d6540da

Please sign in to comment.