File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
tests/integration_tests/performance Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,10 @@ impl VmResources {
261
261
return Err ( VmConfigError :: IncompatibleBalloonSize ) ;
262
262
}
263
263
264
+ if self . balloon . get ( ) . is_some ( ) && updated. huge_pages != HugePageConfig :: None {
265
+ return Err ( VmConfigError :: BalloonAndHugePages ) ;
266
+ }
267
+
264
268
self . vm_config = updated;
265
269
266
270
Ok ( ( ) )
@@ -325,6 +329,10 @@ impl VmResources {
325
329
return Err ( BalloonConfigError :: TooManyPagesRequested ) ;
326
330
}
327
331
332
+ if self . vm_config . huge_pages != HugePageConfig :: None {
333
+ return Err ( BalloonConfigError :: HugePages ) ;
334
+ }
335
+
328
336
self . balloon . set ( config)
329
337
}
330
338
@@ -1389,6 +1397,9 @@ mod tests {
1389
1397
1390
1398
if KernelVersion :: get ( ) . unwrap ( ) >= KernelVersion :: new ( 5 , 10 , 0 ) {
1391
1399
aux_vm_config. mem_size_mib = Some ( 2048 ) ;
1400
+ // Remove the balloon device config that's added by `default_vm_resources` as it would
1401
+ // trigger the "ballooning incompatible with huge pages" check.
1402
+ vm_resources. balloon = BalloonBuilder :: new ( ) ;
1392
1403
vm_resources. update_vm_config ( & aux_vm_config) . unwrap ( ) ;
1393
1404
}
1394
1405
}
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ pub enum BalloonConfigError {
28
28
CreateFailure ( crate :: devices:: virtio:: balloon:: BalloonError ) ,
29
29
/// Error updating the balloon device configuration: {0:?}
30
30
UpdateFailure ( std:: io:: Error ) ,
31
+ /// Firecracker's huge pages support is incompatible with memory ballooning.
32
+ HugePages ,
31
33
}
32
34
33
35
/// This struct represents the strongly typed equivalent of the json body
Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ pub enum VmConfigError {
33
33
KernelVersion ,
34
34
/// Firecracker's hugetlbfs support requires at least host kernel 5.10.
35
35
HugetlbfsNotSupported ,
36
+ /// Firecracker's huge pages support is incompatible with memory ballooning.
37
+ BalloonAndHugePages ,
36
38
}
37
39
38
40
// We cannot do a `KernelVersion(kernel_version::Error)` variant because `kernel_version::Error`
Original file line number Diff line number Diff line change @@ -112,3 +112,30 @@ def test_hugetlbfs_snapshot(
112
112
assert not rc
113
113
114
114
check_hugetlbfs_in_use (vm .firecracker_pid , "/anon_hugepage" )
115
+
116
+
117
+ @pytest .mark .skipif (
118
+ global_props .host_linux_version == "4.14" ,
119
+ reason = "MFD_HUGETLB | MFD_ALLOW_SEALING only supported on kernels >= 4.16" ,
120
+ )
121
+ def test_negative_huge_pages_plus_balloon (uvm_plain ):
122
+ """Tests that huge pages and memory ballooning cannot be used together"""
123
+ uvm_plain .memory_monitor = None
124
+ uvm_plain .spawn ()
125
+
126
+ # Ensure setting huge pages and then adding a balloon device doesn't work
127
+ uvm_plain .basic_config (huge_pages = HugePagesConfig .HUGETLBFS_2MB )
128
+ with pytest .raises (
129
+ RuntimeError ,
130
+ match = "Firecracker's huge pages support is incompatible with memory ballooning." ,
131
+ ):
132
+ uvm_plain .api .balloon .put (amount_mib = 0 , deflate_on_oom = False )
133
+
134
+ # Ensure adding a balloon device and then setting huge pages doesn't work
135
+ uvm_plain .basic_config (huge_pages = HugePagesConfig .NONE )
136
+ uvm_plain .api .balloon .put (amount_mib = 0 , deflate_on_oom = False )
137
+ with pytest .raises (
138
+ RuntimeError ,
139
+ match = "Machine config error: Firecracker's huge pages support is incompatible with memory ballooning." ,
140
+ ):
141
+ uvm_plain .basic_config (huge_pages = HugePagesConfig .HUGETLBFS_2MB )
You can’t perform that action at this time.
0 commit comments