vm-device, vmm: Wait for barrier if one is returned

Wait for the barrier if one is provided by the result of the MMIO and
PIO write.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2020-12-04 10:17:51 +00:00
parent 1fc6d50f3e
commit a8643dc523
2 changed files with 28 additions and 12 deletions

View File

@@ -231,13 +231,13 @@ impl Bus {
/// Writes `data` to the device that owns the range containing `addr`.
///
/// Returns true on success, otherwise `data` is untouched.
pub fn write(&self, addr: u64, data: &[u8]) -> Result<()> {
pub fn write(&self, addr: u64, data: &[u8]) -> Result<Option<Arc<Barrier>>> {
if let Some((base, offset, dev)) = self.resolve(addr) {
// OK to unwrap as lock() failing is a serious error condition and should panic.
dev.lock()
Ok(dev
.lock()
.expect("Failed to acquire device lock")
.write(base, offset, data);
Ok(())
.write(base, offset, data))
} else {
Err(Error::MissingAddressRange)
}