From 545ea9ea33219ee50de7dbc31333a7acbf1a132f Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 14 Feb 2020 10:07:00 +0000 Subject: [PATCH] vm-virtio: Add shutdown method to VirtioDevice trait This allows the VMM to explicitly shutdown devices as part of the VM shutdown ahead of what Drop::drop() would do. Signed-off-by: Rob Bradford --- vm-virtio/src/device.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vm-virtio/src/device.rs b/vm-virtio/src/device.rs index 1a372eea4..41f253972 100644 --- a/vm-virtio/src/device.rs +++ b/vm-virtio/src/device.rs @@ -101,6 +101,12 @@ pub trait VirtioDevice: Send { fn iommu_translate(&self, addr: u64) -> u64 { addr } + + /// Some devices may need to do some explicit shutdown work. This method + /// may be implemented to do this. The VMM should call shutdown() on + /// every device as part of shutting down the VM. Acting on the device + /// after a shutdown() can lead to unpredictable results. + fn shutdown(&mut self) {} } /// Trait providing address translation the same way a physical DMA remapping