Skip to content

Commit aa07f77

Browse files
committed
chore: Cleanup 4.14 related logic in hugepages feature
Hugepages wasn't supported on host kernel 4.14 due to memfd_create not allowing the combination of MFD_HUGETLB and MFD_ALLOW_SEALING. Now that Signed-off-by: Patrick Roy <[email protected]>
1 parent 9b6f067 commit aa07f77

File tree

2 files changed

+27
-63
lines changed

2 files changed

+27
-63
lines changed

src/vmm/src/resources.rs

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ mod tests {
501501
use std::str::FromStr;
502502

503503
use serde_json::{Map, Value};
504-
use utils::kernel_version::KernelVersion;
505504
use utils::net::mac::MacAddr;
506505
use utils::tempfile::TempFile;
507506

@@ -1409,14 +1408,12 @@ mod tests {
14091408
VmConfigError::InvalidMemorySize
14101409
);
14111410

1412-
if KernelVersion::get().unwrap() >= KernelVersion::new(5, 10, 0) {
1413-
// mem_size_mib compatible with huge page configuration
1414-
aux_vm_config.mem_size_mib = Some(2048);
1415-
// Remove the balloon device config that's added by `default_vm_resources` as it would
1416-
// trigger the "ballooning incompatible with huge pages" check.
1417-
vm_resources.balloon = BalloonBuilder::new();
1418-
vm_resources.update_vm_config(&aux_vm_config).unwrap();
1419-
}
1411+
// mem_size_mib compatible with huge page configuration
1412+
aux_vm_config.mem_size_mib = Some(2048);
1413+
// Remove the balloon device config that's added by `default_vm_resources` as it would
1414+
// trigger the "ballooning incompatible with huge pages" check.
1415+
vm_resources.balloon = BalloonBuilder::new();
1416+
vm_resources.update_vm_config(&aux_vm_config).unwrap();
14201417
}
14211418

14221419
#[test]
@@ -1454,29 +1451,27 @@ mod tests {
14541451

14551452
#[test]
14561453
fn test_negative_restore_balloon_device_with_huge_pages() {
1457-
if KernelVersion::get().unwrap() >= KernelVersion::new(4, 16, 0) {
1458-
let mut vm_resources = default_vm_resources();
1459-
vm_resources.balloon = BalloonBuilder::new();
1460-
vm_resources
1461-
.update_vm_config(&MachineConfigUpdate {
1462-
huge_pages: Some(HugePageConfig::Hugetlbfs2M),
1463-
..Default::default()
1464-
})
1465-
.unwrap();
1466-
let err = vm_resources
1467-
.update_from_restored_device(SharedDeviceType::Balloon(Arc::new(Mutex::new(
1468-
Balloon::new(128, false, 0, true).unwrap(),
1469-
))))
1470-
.unwrap_err();
1471-
assert!(
1472-
matches!(
1473-
err,
1474-
ResourcesError::BalloonDevice(BalloonConfigError::HugePages)
1475-
),
1476-
"{:?}",
1477-
err
1478-
);
1479-
}
1454+
let mut vm_resources = default_vm_resources();
1455+
vm_resources.balloon = BalloonBuilder::new();
1456+
vm_resources
1457+
.update_vm_config(&MachineConfigUpdate {
1458+
huge_pages: Some(HugePageConfig::Hugetlbfs2M),
1459+
..Default::default()
1460+
})
1461+
.unwrap();
1462+
let err = vm_resources
1463+
.update_from_restored_device(SharedDeviceType::Balloon(Arc::new(Mutex::new(
1464+
Balloon::new(128, false, 0, true).unwrap(),
1465+
))))
1466+
.unwrap_err();
1467+
assert!(
1468+
matches!(
1469+
err,
1470+
ResourcesError::BalloonDevice(BalloonConfigError::HugePages)
1471+
),
1472+
"{:?}",
1473+
err
1474+
);
14801475
}
14811476

14821477
#[test]

src/vmm/src/vmm_config/machine_config.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::fmt::Debug;
44

55
use serde::{Deserialize, Serialize};
66
use utils::kernel_version;
7-
use utils::kernel_version::KernelVersion;
87

98
use crate::cpu_config::templates::{CpuTemplateType, CustomCpuTemplate, StaticCpuTemplate};
109

@@ -31,8 +30,6 @@ pub enum VmConfigError {
3130
SmtNotSupported,
3231
/// Could not determine host kernel version when checking hugetlbfs compatibility
3332
KernelVersion,
34-
/// Firecracker's hugetlbfs support requires at least host kernel 5.10.
35-
HugetlbfsNotSupported,
3633
/// Firecracker's huge pages support is incompatible with memory ballooning.
3734
BalloonAndHugePages,
3835
/// Firecracker's huge pages support is incompatible with initrds.
@@ -243,10 +240,6 @@ impl VmConfig {
243240
Some(other) => Some(CpuTemplateType::Static(other)),
244241
};
245242

246-
if page_config.is_hugetlbfs() && KernelVersion::get()? < KernelVersion::new(4, 16, 0) {
247-
return Err(VmConfigError::HugetlbfsNotSupported);
248-
}
249-
250243
Ok(VmConfig {
251244
vcpu_count,
252245
mem_size_mib,
@@ -283,27 +276,3 @@ impl From<&VmConfig> for MachineConfig {
283276
}
284277
}
285278
}
286-
287-
#[cfg(test)]
288-
mod tests {
289-
use utils::kernel_version::KernelVersion;
290-
291-
use crate::vmm_config::machine_config::{
292-
HugePageConfig, MachineConfigUpdate, VmConfig, VmConfigError,
293-
};
294-
295-
#[test]
296-
fn test_hugetlbfs_not_supported_4_14() {
297-
if KernelVersion::get().unwrap() < KernelVersion::new(4, 16, 0) {
298-
let base_config = VmConfig::default();
299-
let update = MachineConfigUpdate {
300-
huge_pages: Some(HugePageConfig::Hugetlbfs2M),
301-
mem_size_mib: Some(1024),
302-
..Default::default()
303-
};
304-
305-
let err = base_config.update(&update).unwrap_err();
306-
assert_eq!(err, VmConfigError::HugetlbfsNotSupported)
307-
}
308-
}
309-
}

0 commit comments

Comments
 (0)