3
3
4
4
use serde:: { Deserialize , Serialize } ;
5
5
6
- use crate :: devices:: virtio:: mem:: { VIRTIO_MEM_DEFAULT_BLOCK_SIZE , VIRTIO_MEM_DEFAULT_SLOT_SIZE } ;
7
- use crate :: utils:: bytes_to_mib;
6
+ use crate :: devices:: virtio:: mem:: {
7
+ VIRTIO_MEM_DEFAULT_BLOCK_SIZE_MIB , VIRTIO_MEM_DEFAULT_SLOT_SIZE_MIB ,
8
+ } ;
8
9
9
10
/// Errors associated with memory hotplug configuration.
10
11
#[ derive( Debug , thiserror:: Error , displaydoc:: Display ) ]
@@ -24,11 +25,11 @@ pub enum MemoryHotplugConfigError {
24
25
}
25
26
26
27
fn default_block_size_mib ( ) -> usize {
27
- bytes_to_mib ( VIRTIO_MEM_DEFAULT_BLOCK_SIZE )
28
+ VIRTIO_MEM_DEFAULT_BLOCK_SIZE_MIB
28
29
}
29
30
30
31
fn default_slot_size_mib ( ) -> usize {
31
- bytes_to_mib ( VIRTIO_MEM_DEFAULT_SLOT_SIZE )
32
+ VIRTIO_MEM_DEFAULT_SLOT_SIZE_MIB
32
33
}
33
34
34
35
/// Configuration for memory hotplug device.
@@ -48,7 +49,7 @@ pub struct MemoryHotplugConfig {
48
49
impl MemoryHotplugConfig {
49
50
/// Validates the configuration.
50
51
pub fn validate ( & self ) -> Result < ( ) , MemoryHotplugConfigError > {
51
- let min_block_size_mib = bytes_to_mib ( VIRTIO_MEM_DEFAULT_BLOCK_SIZE ) ;
52
+ let min_block_size_mib = VIRTIO_MEM_DEFAULT_BLOCK_SIZE_MIB ;
52
53
if self . block_size_mib < min_block_size_mib {
53
54
return Err ( MemoryHotplugConfigError :: BlockSizeTooSmall (
54
55
min_block_size_mib,
@@ -58,7 +59,7 @@ impl MemoryHotplugConfig {
58
59
return Err ( MemoryHotplugConfigError :: BlockSizeNotPowerOfTwo ) ;
59
60
}
60
61
61
- let min_slot_size_mib = bytes_to_mib ( VIRTIO_MEM_DEFAULT_SLOT_SIZE ) ;
62
+ let min_slot_size_mib = VIRTIO_MEM_DEFAULT_SLOT_SIZE_MIB ;
62
63
if self . slot_size_mib < min_slot_size_mib {
63
64
return Err ( MemoryHotplugConfigError :: SlotSizeTooSmall (
64
65
min_slot_size_mib,
0 commit comments