diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2019-11-01 10:34:02 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-18 07:43:04 +0000 |
commit | 5eca9379410b0d2422d540dded995523edf6fdc9 (patch) | |
tree | 1f5d3c082242d4820cd8f1cdc2c72e0bbc9bff47 /devices/src | |
parent | 24eeed2b6fb6306f404238d1343db4b55aa9beef (diff) | |
download | crosvm-5eca9379410b0d2422d540dded995523edf6fdc9.tar crosvm-5eca9379410b0d2422d540dded995523edf6fdc9.tar.gz crosvm-5eca9379410b0d2422d540dded995523edf6fdc9.tar.bz2 crosvm-5eca9379410b0d2422d540dded995523edf6fdc9.tar.lz crosvm-5eca9379410b0d2422d540dded995523edf6fdc9.tar.xz crosvm-5eca9379410b0d2422d540dded995523edf6fdc9.tar.zst crosvm-5eca9379410b0d2422d540dded995523edf6fdc9.zip |
devices: virtio: use signal helper for config changes
Add handling of the virtio device MSI-X configuration change vector by using the signal function that was previously factored out. BUG=chromium:854765 TEST=./build_test TEST=trigger disk config change with `crosvm disk resize ...` Change-Id: I462c23e10d152f896586bb70b95634a53088d480 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898269 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zide Chen <zide.chen@intel.corp-partner.google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'devices/src')
-rw-r--r-- | devices/src/virtio/interrupt.rs | 10 | ||||
-rw-r--r-- | devices/src/virtio/vhost/net.rs | 2 | ||||
-rw-r--r-- | devices/src/virtio/virtio_pci_device.rs | 1 |
3 files changed, 8 insertions, 5 deletions
diff --git a/devices/src/virtio/interrupt.rs b/devices/src/virtio/interrupt.rs index 0665b3f..f808d84 100644 --- a/devices/src/virtio/interrupt.rs +++ b/devices/src/virtio/interrupt.rs @@ -14,6 +14,7 @@ pub struct Interrupt { interrupt_evt: EventFd, interrupt_resample_evt: EventFd, msix_config: Option<Arc<Mutex<MsixConfig>>>, + config_msix_vector: u16, } impl Interrupt { @@ -22,12 +23,14 @@ impl Interrupt { interrupt_evt: EventFd, interrupt_resample_evt: EventFd, msix_config: Option<Arc<Mutex<MsixConfig>>>, + config_msix_vector: u16, ) -> Interrupt { Interrupt { interrupt_status, interrupt_evt, interrupt_resample_evt, msix_config, + config_msix_vector, } } @@ -64,12 +67,9 @@ impl Interrupt { self.signal(vector, INTERRUPT_STATUS_USED_RING) } - /// Notification of Device Configuration Changes - /// Set BIT1 in ISR and write to irqfd + /// Notify the driver that the device configuration has changed. pub fn signal_config_changed(&self) { - self.interrupt_status - .fetch_or(INTERRUPT_STATUS_CONFIG_CHANGED as usize, Ordering::SeqCst); - self.interrupt_evt.write(1).unwrap(); + self.signal(self.config_msix_vector, INTERRUPT_STATUS_CONFIG_CHANGED) } /// Handle interrupt resampling event diff --git a/devices/src/virtio/vhost/net.rs b/devices/src/virtio/vhost/net.rs index 1196200..8462da5 100644 --- a/devices/src/virtio/vhost/net.rs +++ b/devices/src/virtio/vhost/net.rs @@ -233,6 +233,7 @@ where #[cfg(test)] pub mod tests { use super::*; + use crate::virtio::VIRTIO_MSI_NO_VECTOR; use net_util::fakes::FakeTap; use std::result; use std::sync::atomic::AtomicUsize; @@ -295,6 +296,7 @@ pub mod tests { EventFd::new().unwrap(), EventFd::new().unwrap(), None, + VIRTIO_MSI_NO_VECTOR, ), vec![Queue::new(1)], vec![EventFd::new().unwrap()], diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs index c535ab5..b79a98a 100644 --- a/devices/src/virtio/virtio_pci_device.rs +++ b/devices/src/virtio/virtio_pci_device.rs @@ -618,6 +618,7 @@ impl PciDevice for VirtioPciDevice { interrupt_evt, interrupt_resample_evt, msix_config, + self.common_config.msix_config, ); self.device.activate( |