diff options
author | Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> | 2019-09-17 14:17:19 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-24 20:46:41 +0000 |
commit | a5d248c86382a255c84a2592db67f6ef9887b2a1 (patch) | |
tree | fc6ce6e5f91dbc69ea678baa85ebd1182fa2b1b7 /devices/src/virtio/virtio_pci_device.rs | |
parent | d6be9614baea746efbc2744d7a914c95e315ea63 (diff) | |
download | crosvm-a5d248c86382a255c84a2592db67f6ef9887b2a1.tar crosvm-a5d248c86382a255c84a2592db67f6ef9887b2a1.tar.gz crosvm-a5d248c86382a255c84a2592db67f6ef9887b2a1.tar.bz2 crosvm-a5d248c86382a255c84a2592db67f6ef9887b2a1.tar.lz crosvm-a5d248c86382a255c84a2592db67f6ef9887b2a1.tar.xz crosvm-a5d248c86382a255c84a2592db67f6ef9887b2a1.tar.zst crosvm-a5d248c86382a255c84a2592db67f6ef9887b2a1.zip |
devices: implement MSI control socket
Allocate per device VmMsi msg_socket for communication between virtio devices and main VM process, which owns the KVM fd and issues ioctl to KVM for KVM_IRQFD and KVM_SET_GSI_ROUTING. BUG=chromium:854765 TEST=None Change-Id: Ie1c81534912eaab7fbf05b5edef7dca343db301c Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Signed-off-by: Zide Chen <zide.chen@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1828339 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'devices/src/virtio/virtio_pci_device.rs')
-rw-r--r-- | devices/src/virtio/virtio_pci_device.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs index 2110b75..713329f 100644 --- a/devices/src/virtio/virtio_pci_device.rs +++ b/devices/src/virtio/virtio_pci_device.rs @@ -19,6 +19,8 @@ use crate::pci::{ PciConfiguration, PciDevice, PciDeviceError, PciHeaderType, PciInterruptPin, PciSubclass, }; +use vm_control::VmIrqRequestSocket; + use self::virtio_pci_common_config::VirtioPciCommonConfig; pub enum PciCapabilityType { @@ -172,7 +174,11 @@ pub struct VirtioPciDevice { impl VirtioPciDevice { /// Constructs a new PCI transport for the given virtio device. - pub fn new(mem: GuestMemory, device: Box<dyn VirtioDevice>) -> Result<Self> { + pub fn new( + mem: GuestMemory, + device: Box<dyn VirtioDevice>, + msi_device_socket: Option<VmIrqRequestSocket>, + ) -> Result<Self> { let mut queue_evts = Vec::new(); for _ in device.queue_max_sizes() { queue_evts.push(EventFd::new()?) @@ -186,8 +192,11 @@ impl VirtioPciDevice { let pci_device_id = VIRTIO_PCI_DEVICE_ID_BASE + device.device_type() as u16; let msix_num = device.msix_vectors(); - let msix_config = if msix_num > 0 { - let msix_config = Arc::new(Mutex::new(MsixConfig::new(msix_num))); + let msix_config = if msix_num > 0 && msi_device_socket.is_some() { + let msix_config = Arc::new(Mutex::new(MsixConfig::new( + msix_num, + msi_device_socket.unwrap(), + ))); Some(msix_config) } else { None @@ -346,6 +355,10 @@ impl PciDevice for VirtioPciDevice { if let Some(interrupt_resample_evt) = &self.interrupt_resample_evt { fds.push(interrupt_resample_evt.as_raw_fd()); } + if let Some(msix_config) = &self.msix_config { + let fd = msix_config.lock().get_msi_socket(); + fds.push(fd); + } fds } |