summary refs log tree commit diff
path: root/src/linux.rs
diff options
context:
space:
mode:
authorXiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>2019-04-23 17:15:21 +0800
committerCommit Bot <commit-bot@chromium.org>2019-10-29 11:10:47 +0000
commit4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717 (patch)
tree084c2ed952fec8903e6c086e3f3091c2e7ae3918 /src/linux.rs
parentee723d5204f8a0741cf993900fb6471202db9a97 (diff)
downloadcrosvm-4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717.tar
crosvm-4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717.tar.gz
crosvm-4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717.tar.bz2
crosvm-4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717.tar.lz
crosvm-4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717.tar.xz
crosvm-4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717.tar.zst
crosvm-4b5bb3a4ed3656784172cfabfdcd0d2bbb2b4717.zip
vfio: Add vfio msi routing information into kvm
When vfio device msi is enabled, use VmIrqRequest->AllocateOneMsi() to
allocate one gsi for a msi vector, and link gsi with irqfd through
vm->register_irqfd, use VmIrqRequest->AddMsiRoute() to add msi routing
info into kvm route table.

BUG=chromium:992270
TEST=none

Change-Id: I5e2d2347e5e26f0ef6e12554dae4b12934b65e82
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581146
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/linux.rs')
-rw-r--r--src/linux.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/linux.rs b/src/linux.rs
index 31b9d32..0266721 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -258,7 +258,6 @@ type Result<T> = std::result::Result<T, Error>;
 enum TaggedControlSocket {
     Vm(VmControlResponseSocket),
     VmMemory(VmMemoryControlResponseSocket),
-    #[allow(dead_code)]
     VmIrq(VmIrqResponseSocket),
 }
 
@@ -1000,10 +999,14 @@ fn create_devices(
     pci_devices.push((usb_controller, simple_jail(&cfg, "xhci.policy")?));
 
     if cfg.vfio.is_some() {
+        let (vfio_host_socket_irq, vfio_device_socket_irq) =
+            msg_socket::pair::<VmIrqResponse, VmIrqRequest>().map_err(Error::CreateSocket)?;
+        control_sockets.push(TaggedControlSocket::VmIrq(vfio_host_socket_irq));
+
         let vfio_path = cfg.vfio.as_ref().unwrap().as_path();
         let vfiodevice =
             VfioDevice::new(vfio_path, vm, mem.clone()).map_err(Error::CreateVfioDevice)?;
-        let vfiopcidevice = Box::new(VfioPciDevice::new(vfiodevice));
+        let vfiopcidevice = Box::new(VfioPciDevice::new(vfiodevice, vfio_device_socket_irq));
         pci_devices.push((vfiopcidevice, simple_jail(&cfg, "vfio_device.policy")?));
     }