diff --git a/hypervisor/src/kvm/x86_64.rs b/hypervisor/src/kvm/x86_64.rs index 6bdb323c38..4e6b08b494 100644 --- a/hypervisor/src/kvm/x86_64.rs +++ b/hypervisor/src/kvm/x86_64.rs @@ -22,6 +22,7 @@ use data_model::vec_with_array_field; use data_model::FlexibleArrayWrapper; use kvm_sys::*; use libc::E2BIG; +use libc::EAGAIN; use libc::EIO; use libc::ENXIO; use serde::Deserialize; @@ -565,6 +566,10 @@ impl VcpuX86_64 for KvmVcpu { /// While this ioctl exists on PPC and MIPS as well as x86, the semantics are different and /// ChromeOS doesn't support PPC or MIPS. fn interrupt(&self, irq: u8) -> Result<()> { + if !self.ready_for_interrupt() { + return Err(Error::new(EAGAIN)); + } + let interrupt = kvm_interrupt { irq: irq.into() }; // SAFETY: // safe becuase we allocated the struct and we know the kernel will read