mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: Make Bus::write() return an Option<Arc<Barrier>>
This can be uses to indicate to the caller that it should wait on the barrier before returning as there is some asynchronous activity triggered by the write which requires the KVM exit to block until it's completed. This is useful for having vCPU thread wait for the VMM thread to proceed to activate the virtio devices. See #1863 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
@@ -446,7 +446,7 @@ impl BusDevice for CpuManager {
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&mut self, _base: u64, offset: u64, data: &[u8]) {
|
||||
fn write(&mut self, _base: u64, offset: u64, data: &[u8]) -> Option<Arc<Barrier>> {
|
||||
match offset {
|
||||
CPU_SELECTION_OFFSET => {
|
||||
self.selected_cpu = data[0];
|
||||
@@ -478,6 +478,7 @@ impl BusDevice for CpuManager {
|
||||
);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ use std::os::unix::fs::OpenOptionsExt;
|
||||
#[cfg(feature = "kvm")]
|
||||
use std::os::unix::io::FromRawFd;
|
||||
use std::result;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
#[cfg(feature = "kvm")]
|
||||
use vfio_ioctls::{VfioContainer, VfioDevice, VfioDmaMapping};
|
||||
use virtio_devices::transport::VirtioPciDevice;
|
||||
@@ -3551,7 +3551,7 @@ impl BusDevice for DeviceManager {
|
||||
)
|
||||
}
|
||||
|
||||
fn write(&mut self, base: u64, offset: u64, data: &[u8]) {
|
||||
fn write(&mut self, base: u64, offset: u64, data: &[u8]) -> Option<Arc<Barrier>> {
|
||||
match offset {
|
||||
B0EJ_FIELD_OFFSET => {
|
||||
assert!(data.len() == B0EJ_FIELD_SIZE);
|
||||
@@ -3577,7 +3577,9 @@ impl BusDevice for DeviceManager {
|
||||
debug!(
|
||||
"PCI_HP_REG_W: base 0x{:x}, offset 0x{:x}, data {:?}",
|
||||
base, offset, data
|
||||
)
|
||||
);
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::ops::Deref;
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
||||
use std::path::PathBuf;
|
||||
use std::result;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
use url::Url;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use vm_allocator::GsiApic;
|
||||
@@ -314,7 +314,7 @@ impl BusDevice for MemoryManager {
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&mut self, _base: u64, offset: u64, data: &[u8]) {
|
||||
fn write(&mut self, _base: u64, offset: u64, data: &[u8]) -> Option<Arc<Barrier>> {
|
||||
match offset {
|
||||
SELECTION_OFFSET => {
|
||||
self.selected_slot = usize::from(data[0]);
|
||||
@@ -340,7 +340,8 @@ impl BusDevice for MemoryManager {
|
||||
offset
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user