From 49f071ad4f197e657ea4c497a677009d1788ff63 Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Mon, 11 Mar 2019 10:18:01 -0700 Subject: [PATCH] crosvm: Add KVM_SIGNAL_MSI ioctl. This ioctl is necessary for a userspace IOAPIC. TEST=Built BUG=chromium:908689 Change-Id: I52fc96baef2193e4f673bbce17a1b56ded9aa6a6 Reviewed-on: https://chromium-review.googlesource.com/1515992 Commit-Ready: Miriam Zimmerman Tested-by: Miriam Zimmerman Tested-by: kokoro Reviewed-by: Zach Reizner --- kvm/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs index 1cf91907ca..db3ec656c5 100644 --- a/kvm/src/lib.rs +++ b/kvm/src/lib.rs @@ -941,6 +941,20 @@ impl Vm { cap.args[0] = 24; self.kvm_enable_cap(&cap) } + + /// Request that the kernel inject the specified MSI message. + /// Returns Ok(true) on delivery, Ok(false) if the guest blocked delivery, or an error. + /// See kernel documentation for KVM_SIGNAL_MSI. + pub fn signal_msi(&self, msi: &kvm_msi) -> Result { + // safe becuase we allocated the struct and we know the kernel will read + // exactly the size of the struct + let ret = unsafe { ioctl_with_ref(self, KVM_SIGNAL_MSI(), msi) }; + if ret < 0 { + errno_result() + } else { + Ok(ret > 0) + } + } } impl AsRawFd for Vm {