Skip to content

Commit 62054ef

Browse files
committed
vmm: updated balloon struct field names
Signed-off-by: George Pisaltu <[email protected]>
1 parent db58dce commit 62054ef

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/vmm/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ pub mod tests {
12821282
let mut vmm = default_vmm();
12831283

12841284
let balloon_config = BalloonDeviceConfig {
1285-
amount_mb: 0,
1285+
amount_mib: 0,
12861286
deflate_on_oom: false,
12871287
stats_polling_interval_s: 0,
12881288
};

src/vmm/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,11 @@ impl Vmm {
614614
/// Updates configuration for the balloon device target size.
615615
pub fn update_balloon_config(
616616
&mut self,
617-
amount_mb: u32,
617+
amount_mib: u32,
618618
) -> std::result::Result<(), BalloonError> {
619619
// The balloon cannot have a target size greater than the size of
620620
// the guest memory.
621-
if amount_mb as u64 > mem_size_mib(self.guest_memory()) {
621+
if amount_mib as u64 > mem_size_mib(self.guest_memory()) {
622622
return Err(BalloonError::TooManyPagesRequested);
623623
}
624624

@@ -640,7 +640,7 @@ impl Vmm {
640640
.as_mut_any()
641641
.downcast_mut::<Balloon>()
642642
.unwrap()
643-
.update_size(amount_mb)?;
643+
.update_size(amount_mib)?;
644644
}
645645

646646
let locked_dev = busdev.lock().expect("Poisoned lock");

src/vmm/src/resources.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl VmResources {
198198
.balloon
199199
.get_config()
200200
.map_err(|_| VmConfigError::InvalidVmState)?
201-
.amount_mb as usize
201+
.amount_mib as usize
202202
{
203203
return Err(VmConfigError::IncompatibleBalloonSize);
204204
}
@@ -245,7 +245,7 @@ impl VmResources {
245245
) -> Result<BalloonConfigError> {
246246
// The balloon cannot have a target size greater than the size of
247247
// the guest memory.
248-
if config.amount_mb as usize
248+
if config.amount_mib as usize
249249
> self
250250
.vm_config
251251
.mem_size_mib
@@ -721,7 +721,7 @@ mod tests {
721721
json = format!(
722722
r#"{{
723723
"balloon": {{
724-
"amount_mb": 0,
724+
"amount_mib": 0,
725725
"deflate_on_oom": false,
726726
"stats_polling_interval_s": 0
727727
}},
@@ -817,7 +817,7 @@ mod tests {
817817
vm_resources.vm_config.mem_size_mib = Some(128);
818818
vm_resources
819819
.set_balloon_device(BalloonDeviceConfig {
820-
amount_mb: 100,
820+
amount_mib: 100,
821821
deflate_on_oom: false,
822822
stats_polling_interval_s: 0,
823823
})
@@ -846,7 +846,7 @@ mod tests {
846846
boot_timer: false,
847847
};
848848
let mut new_balloon_cfg = BalloonDeviceConfig {
849-
amount_mb: 100,
849+
amount_mib: 100,
850850
deflate_on_oom: false,
851851
stats_polling_interval_s: 0,
852852
};
@@ -856,7 +856,7 @@ mod tests {
856856
.unwrap();
857857

858858
let actual_balloon_cfg = vm_resources.balloon.get_config().unwrap();
859-
assert_eq!(actual_balloon_cfg.amount_mb, new_balloon_cfg.amount_mb);
859+
assert_eq!(actual_balloon_cfg.amount_mib, new_balloon_cfg.amount_mib);
860860
assert_eq!(
861861
actual_balloon_cfg.deflate_on_oom,
862862
new_balloon_cfg.deflate_on_oom
@@ -876,7 +876,7 @@ mod tests {
876876
mmds_config: None,
877877
boot_timer: false,
878878
};
879-
new_balloon_cfg.amount_mb = 256;
879+
new_balloon_cfg.amount_mib = 256;
880880
assert!(vm_resources.set_balloon_device(new_balloon_cfg).is_err());
881881
}
882882

src/vmm/src/rpc_interface.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl RuntimeApiController {
474474
.vmm
475475
.lock()
476476
.expect("Poisoned lock")
477-
.update_balloon_config(balloon_update.amount_mb)
477+
.update_balloon_config(balloon_update.amount_mib)
478478
.map(|_| VmmData::Empty)
479479
.map_err(|e| VmmActionError::BalloonConfig(BalloonConfigError::from(e))),
480480
UpdateBalloonStatistics(balloon_stats_update) => self
@@ -1201,7 +1201,7 @@ mod tests {
12011201
VmmActionError::OperationNotSupportedPreBoot,
12021202
);
12031203
check_preboot_request_err(
1204-
VmmAction::UpdateBalloon(BalloonUpdateConfig { amount_mb: 0 }),
1204+
VmmAction::UpdateBalloon(BalloonUpdateConfig { amount_mib: 0 }),
12051205
VmmActionError::OperationNotSupportedPreBoot,
12061206
);
12071207
check_preboot_request_err(
@@ -1392,13 +1392,13 @@ mod tests {
13921392

13931393
#[test]
13941394
fn test_runtime_update_balloon_config() {
1395-
let req = VmmAction::UpdateBalloon(BalloonUpdateConfig { amount_mb: 0 });
1395+
let req = VmmAction::UpdateBalloon(BalloonUpdateConfig { amount_mib: 0 });
13961396
check_runtime_request(req, |result, vmm| {
13971397
assert_eq!(result, Ok(VmmData::Empty));
13981398
assert!(vmm.update_balloon_config_called)
13991399
});
14001400

1401-
let req = VmmAction::UpdateBalloon(BalloonUpdateConfig { amount_mb: 0 });
1401+
let req = VmmAction::UpdateBalloon(BalloonUpdateConfig { amount_mib: 0 });
14021402
check_runtime_request_err(
14031403
req,
14041404
VmmActionError::BalloonConfig(BalloonConfigError::DeviceNotFound),

src/vmm/src/vmm_config/balloon.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ type Result<T> = std::result::Result<T, BalloonConfigError>;
7373
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
7474
#[serde(deny_unknown_fields)]
7575
pub struct BalloonDeviceConfig {
76-
/// Target balloon size in MB.
77-
pub amount_mb: u32,
76+
/// Target balloon size in MiB.
77+
pub amount_mib: u32,
7878
/// Option to deflate the balloon in case the guest is out of memory.
7979
pub deflate_on_oom: bool,
8080
/// Interval in seconds between refreshing statistics.
@@ -85,7 +85,7 @@ pub struct BalloonDeviceConfig {
8585
impl From<BalloonConfig> for BalloonDeviceConfig {
8686
fn from(state: BalloonConfig) -> Self {
8787
BalloonDeviceConfig {
88-
amount_mb: state.amount_mb,
88+
amount_mib: state.amount_mib,
8989
deflate_on_oom: state.deflate_on_oom,
9090
stats_polling_interval_s: state.stats_polling_interval_s,
9191
}
@@ -97,8 +97,8 @@ impl From<BalloonConfig> for BalloonDeviceConfig {
9797
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
9898
#[serde(deny_unknown_fields)]
9999
pub struct BalloonUpdateConfig {
100-
/// Target balloon size in MB.
101-
pub amount_mb: u32,
100+
/// Target balloon size in MiB.
101+
pub amount_mib: u32,
102102
}
103103

104104
/// The data fed into a balloon statistics interval update request.
@@ -135,7 +135,7 @@ impl BalloonBuilder {
135135
pub fn set(&mut self, cfg: BalloonDeviceConfig) -> Result<()> {
136136
self.inner = Some(Arc::new(Mutex::new(
137137
Balloon::new(
138-
cfg.amount_mb,
138+
cfg.amount_mib,
139139
cfg.deflate_on_oom,
140140
cfg.stats_polling_interval_s,
141141
// `restored` flag is false because this code path
@@ -168,7 +168,7 @@ pub(crate) mod tests {
168168

169169
pub(crate) fn default_config() -> BalloonDeviceConfig {
170170
BalloonDeviceConfig {
171-
amount_mb: 0,
171+
amount_mib: 0,
172172
deflate_on_oom: false,
173173
stats_polling_interval_s: 0,
174174
}
@@ -186,7 +186,7 @@ pub(crate) mod tests {
186186
fn test_balloon_create() {
187187
let default_balloon_config = default_config();
188188
let balloon_config = BalloonDeviceConfig {
189-
amount_mb: 0,
189+
amount_mib: 0,
190190
deflate_on_oom: false,
191191
stats_polling_interval_s: 0,
192192
};
@@ -198,7 +198,7 @@ pub(crate) mod tests {
198198
assert_eq!(builder.get().unwrap().lock().unwrap().num_pages(), 0);
199199
assert_eq!(builder.get_config().unwrap(), default_balloon_config);
200200

201-
let _update_config = BalloonUpdateConfig { amount_mb: 5 };
201+
let _update_config = BalloonUpdateConfig { amount_mib: 5 };
202202
let _stats_update_config = BalloonUpdateStatsConfig {
203203
stats_polling_interval_s: 5,
204204
};
@@ -207,13 +207,13 @@ pub(crate) mod tests {
207207
#[test]
208208
fn test_from_balloon_state() {
209209
let expected_balloon_config = BalloonDeviceConfig {
210-
amount_mb: 5,
210+
amount_mib: 5,
211211
deflate_on_oom: false,
212212
stats_polling_interval_s: 3,
213213
};
214214

215215
let actual_balloon_config = BalloonDeviceConfig::from(BalloonConfig {
216-
amount_mb: 5,
216+
amount_mib: 5,
217217
deflate_on_oom: false,
218218
stats_polling_interval_s: 3,
219219
});

0 commit comments

Comments
 (0)