@@ -24,37 +24,6 @@ use crate::rate_limiter::persist::RateLimiterState;
24
24
use crate :: rate_limiter:: RateLimiter ;
25
25
use crate :: vstate:: memory:: GuestMemoryMmap ;
26
26
27
- /// Holds info about block's cache type. Gets saved in snapshot.
28
- // NOTICE: Any changes to this structure require a snapshot version bump.
29
- #[ derive( Clone , Copy , Debug , PartialEq , Eq , Versionize ) ]
30
- pub enum CacheTypeState {
31
- /// Flushing mechanic will be advertised to the guest driver, but
32
- /// the operation will be a noop.
33
- Unsafe ,
34
- /// Flushing mechanic will be advertised to the guest driver and
35
- /// flush requests coming from the guest will be performed using
36
- /// `fsync`.
37
- Writeback ,
38
- }
39
-
40
- impl From < CacheType > for CacheTypeState {
41
- fn from ( cache_type : CacheType ) -> Self {
42
- match cache_type {
43
- CacheType :: Unsafe => CacheTypeState :: Unsafe ,
44
- CacheType :: Writeback => CacheTypeState :: Writeback ,
45
- }
46
- }
47
- }
48
-
49
- impl From < CacheTypeState > for CacheType {
50
- fn from ( cache_type_state : CacheTypeState ) -> Self {
51
- match cache_type_state {
52
- CacheTypeState :: Unsafe => CacheType :: Unsafe ,
53
- CacheTypeState :: Writeback => CacheType :: Writeback ,
54
- }
55
- }
56
- }
57
-
58
27
/// Holds info about block's file engine type. Gets saved in snapshot.
59
28
// NOTICE: Any changes to this structure require a snapshot version bump.
60
29
#[ derive( Clone , Copy , Debug , Default , PartialEq , Eq , Versionize ) ]
@@ -93,7 +62,7 @@ pub struct VirtioBlockState {
93
62
id : String ,
94
63
partuuid : Option < String > ,
95
64
#[ version( start = 2 , default_fn = "default_cache_type_flush" ) ]
96
- cache_type : CacheTypeState ,
65
+ cache_type : CacheType ,
97
66
root_device : bool ,
98
67
disk_path : String ,
99
68
virtio_state : VirtioDeviceState ,
@@ -103,8 +72,8 @@ pub struct VirtioBlockState {
103
72
}
104
73
105
74
impl VirtioBlockState {
106
- fn default_cache_type_flush ( _source_version : u16 ) -> CacheTypeState {
107
- CacheTypeState :: Unsafe
75
+ fn default_cache_type_flush ( _source_version : u16 ) -> CacheType {
76
+ CacheType :: Unsafe
108
77
}
109
78
}
110
79
@@ -125,7 +94,7 @@ impl Persist<'_> for VirtioBlock {
125
94
VirtioBlockState {
126
95
id : self . id . clone ( ) ,
127
96
partuuid : self . partuuid . clone ( ) ,
128
- cache_type : CacheTypeState :: from ( self . cache_type ( ) ) ,
97
+ cache_type : self . cache_type ( ) ,
129
98
root_device : self . root_device ,
130
99
disk_path : self . disk . file_path ( ) . clone ( ) ,
131
100
virtio_state : VirtioDeviceState :: from_device ( self ) ,
@@ -223,36 +192,6 @@ mod tests {
223
192
use crate :: devices:: virtio:: device:: VirtioDevice ;
224
193
use crate :: devices:: virtio:: test_utils:: default_mem;
225
194
226
- #[ test]
227
- fn test_cache_type_state_from ( ) {
228
- assert_eq ! (
229
- CacheTypeState :: Unsafe ,
230
- CacheTypeState :: from( CacheType :: Unsafe )
231
- ) ;
232
- assert_eq ! (
233
- CacheTypeState :: Writeback ,
234
- CacheTypeState :: from( CacheType :: Writeback )
235
- ) ;
236
- }
237
-
238
- #[ test]
239
- fn test_cache_type_state_into ( ) {
240
- assert_eq ! ( CacheType :: Unsafe , CacheTypeState :: Unsafe . into( ) ) ;
241
- assert_eq ! ( CacheType :: Writeback , CacheTypeState :: Writeback . into( ) ) ;
242
- }
243
-
244
- #[ test]
245
- fn test_default_cache_type_flush ( ) {
246
- assert_eq ! (
247
- VirtioBlockState :: default_cache_type_flush( 2 ) ,
248
- CacheTypeState :: Unsafe
249
- ) ;
250
- assert_eq ! (
251
- VirtioBlockState :: default_cache_type_flush( 3 ) ,
252
- CacheTypeState :: Unsafe
253
- ) ;
254
- }
255
-
256
195
#[ test]
257
196
fn test_cache_semantic_ser ( ) {
258
197
// We create the backing file here so that it exists for the whole lifetime of the test.
0 commit comments