Reset device when the transport is dropped.
@@ -490,3 +490,10 @@ impl Transport for MmioTransport {
Ok(NonNull::new((self.header.as_ptr() as usize + CONFIG_SPACE_OFFSET) as _).unwrap())
}
+
+impl Drop for MmioTransport {
+ fn drop(&mut self) {
+ // Reset the device when the transport is dropped.
+ self.set_status(DeviceStatus::empty())
+ }
+}
@@ -338,6 +338,13 @@ impl Transport for PciTransport {
+impl Drop for PciTransport {
/// `virtio_pci_common_cfg`, see 4.1.4.3 "Common configuration structure layout".
#[repr(C)]
struct CommonCfg {