diff --git a/vm-device/src/bus.rs b/vm-device/src/bus.rs index 381859319..3388ee205 100644 --- a/vm-device/src/bus.rs +++ b/vm-device/src/bus.rs @@ -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>> { 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) } diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 24703d718..0e15999bd 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -400,11 +400,19 @@ impl VmmOps for VmOps { } fn mmio_write(&self, addr: u64, data: &[u8]) -> hypervisor::vm::Result<()> { - if let Err(e) = self.mmio_bus.write(addr, data) { - if let vm_device::BusError::MissingAddressRange = e { - warn!("Guest MMIO write to unregistered address 0x{:x}", addr); + match self.mmio_bus.write(addr, data) { + Err(e) => { + if let vm_device::BusError::MissingAddressRange = e { + warn!("Guest MMIO write to unregistered address 0x{:x}", addr); + } } - } + Ok(Some(barrier)) => { + info!("Waiting for barrier"); + barrier.wait(); + info!("Barrier released"); + } + _ => {} + }; Ok(()) } @@ -425,11 +433,19 @@ impl VmmOps for VmOps { return Ok(()); } - if let Err(e) = self.io_bus.write(addr, data) { - if let vm_device::BusError::MissingAddressRange = e { - warn!("Guest PIO write to unregistered address 0x{:x}", addr); + match self.io_bus.write(addr, data) { + Err(e) => { + if let vm_device::BusError::MissingAddressRange = e { + warn!("Guest PIO write to unregistered address 0x{:x}", addr); + } } - } + Ok(Some(barrier)) => { + info!("Waiting for barrier"); + barrier.wait(); + info!("Barrier released"); + } + _ => {} + }; Ok(()) } }