@@ -18,11 +18,14 @@ use super::device::*;
1818use super :: queue:: * ;
1919use crate :: devices:: virtio:: MmioTransport ;
2020
21+ /// Errors thrown during restoring virtio state.
2122#[ derive( Debug ) ]
2223pub enum PersistError {
24+ /// Snapshot state contains invalid queue info.
2325 InvalidInput ,
2426}
2527
28+ /// Queue information saved in snapshot.
2629#[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
2730// NOTICE: Any changes to this structure require a snapshot version bump.
2831pub struct QueueState {
@@ -91,15 +94,22 @@ impl Persist<'_> for Queue {
9194#[ derive( Clone , Debug , Default , PartialEq , Eq , Versionize ) ]
9295// NOTICE: Any changes to this structure require a snapshot version bump.
9396pub struct VirtioDeviceState {
97+ /// Device type.
9498 pub device_type : u32 ,
99+ /// Available virtio features.
95100 pub avail_features : u64 ,
101+ /// Negotiated virtio features.
96102 pub acked_features : u64 ,
103+ /// List of queues.
97104 pub queues : Vec < QueueState > ,
105+ /// The MMIO interrupt status.
98106 pub interrupt_status : usize ,
107+ /// Flag for activated status.
99108 pub activated : bool ,
100109}
101110
102111impl VirtioDeviceState {
112+ /// Construct the virtio state of a device.
103113 pub fn from_device ( device : & dyn VirtioDevice ) -> Self {
104114 VirtioDeviceState {
105115 device_type : device. device_type ( ) ,
@@ -162,6 +172,7 @@ impl VirtioDeviceState {
162172 }
163173}
164174
175+ /// Transport information saved in snapshot.
165176#[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
166177// NOTICE: Any changes to this structure require a snapshot version bump.
167178pub struct MmioTransportState {
@@ -174,9 +185,12 @@ pub struct MmioTransportState {
174185 config_generation : u32 ,
175186}
176187
188+ /// Auxiliary structure for initializing the transport when resuming from a snapshot.
177189#[ derive( Debug ) ]
178190pub struct MmioTransportConstructorArgs {
191+ /// Pointer to guest memory.
179192 pub mem : GuestMemoryMmap ,
193+ /// Device associated with the current MMIO state.
180194 pub device : Arc < Mutex < dyn VirtioDevice > > ,
181195}
182196
0 commit comments