Skip to content

Commit acf806d

Browse files
committed
allow combination of initrd and hugepages
After simply giving it a try, it seems that this combination of features actually works. So remove all the error branches that disallow it, and update the negative test into a positive test. Signed-off-by: Patrick Roy <[email protected]>
1 parent 9054afc commit acf806d

File tree

5 files changed

+14
-45
lines changed

5 files changed

+14
-45
lines changed

docs/hugepages.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Currently, hugetlbfs support is mutually exclusive with the following
3939
Firecracker features:
4040

4141
- Memory Ballooning via the [Balloon Device](./ballooning.md)
42-
- Initrd
4342

4443
## FAQ
4544

src/vmm/src/resources.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,6 @@ impl VmResources {
264264
if self.balloon.get().is_some() && updated.huge_pages != HugePageConfig::None {
265265
return Err(MachineConfigError::BalloonAndHugePages);
266266
}
267-
268-
if self.boot_source.config.initrd_path.is_some()
269-
&& updated.huge_pages != HugePageConfig::None
270-
{
271-
return Err(MachineConfigError::InitrdAndHugePages);
272-
}
273-
274267
self.machine_config = updated;
275268

276269
Ok(())
@@ -337,12 +330,6 @@ impl VmResources {
337330
&mut self,
338331
boot_source_cfg: BootSourceConfig,
339332
) -> Result<(), BootSourceConfigError> {
340-
if boot_source_cfg.initrd_path.is_some()
341-
&& self.machine_config.huge_pages != HugePageConfig::None
342-
{
343-
return Err(BootSourceConfigError::HugePagesAndInitRd);
344-
}
345-
346333
self.boot_source = BootSource {
347334
builder: Some(BootConfig::new(&boot_source_cfg)?),
348335
config: boot_source_cfg,

src/vmm/src/vmm_config/boot_source.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ pub enum BootSourceConfigError {
4242
InvalidInitrdPath(io::Error),
4343
/// The kernel command line is invalid: {0}
4444
InvalidKernelCommandLine(String),
45-
/// Firecracker's huge pages support is incompatible with initrds.
46-
HugePagesAndInitRd,
4745
}
4846

4947
/// Holds the kernel specification (both configuration as well as runtime details).

src/vmm/src/vmm_config/machine_config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ pub enum MachineConfigError {
3131
KernelVersion,
3232
/// Firecracker's huge pages support is incompatible with memory ballooning.
3333
BalloonAndHugePages,
34-
/// Firecracker's huge pages support is incompatible with initrds.
35-
InitrdAndHugePages,
3634
}
3735

3836
/// Describes the possible (huge)page configurations for a microVM's memory.

tests/integration_tests/performance/test_huge_pages.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
import pytest
88

99
from framework import utils
10-
from framework.microvm import HugePagesConfig
10+
from framework.microvm import HugePagesConfig, Serial
1111
from framework.properties import global_props
1212
from framework.utils_ftrace import ftrace_events
13+
from integration_tests.functional.test_initrd import INITRD_FILESYSTEM
1314
from integration_tests.functional.test_uffd import SOCKET_PATH, spawn_pf_handler
1415

1516

@@ -259,33 +260,19 @@ def test_negative_huge_pages_plus_initrd(uvm_with_initrd):
259260
uvm_with_initrd.spawn()
260261
uvm_with_initrd.memory_monitor = None
261262

262-
# Ensure setting huge pages and then telling FC to boot an initrd does not work
263-
with pytest.raises(
264-
RuntimeError,
265-
match="Boot source error: Firecracker's huge pages support is incompatible with initrds.",
266-
):
267-
# `basic_config` first does a PUT to /machine-config, which will apply the huge pages configuration,
268-
# and then a PUT to /boot-source, which will register the initrd
269-
uvm_with_initrd.basic_config(
270-
boot_args="console=ttyS0 reboot=k panic=1 pci=off",
271-
use_initrd=True,
272-
huge_pages=HugePagesConfig.HUGETLBFS_2MB,
273-
add_root_device=False,
274-
vcpu_count=1,
275-
)
276-
277-
# Ensure telling FC about the initrd first and then setting huge pages doesn't work
278-
# This first does a PUT to /machine-config to reset the huge pages configuration, before doing a
279-
# PUT to /boot-source to register the initrd
263+
# `basic_config` first does a PUT to /machine-config, which will apply the huge pages configuration,
264+
# and then a PUT to /boot-source, which will register the initrd
280265
uvm_with_initrd.basic_config(
281-
huge_pages=HugePagesConfig.NONE,
282266
boot_args="console=ttyS0 reboot=k panic=1 pci=off",
283267
use_initrd=True,
268+
huge_pages=HugePagesConfig.HUGETLBFS_2MB,
269+
add_root_device=False,
270+
vcpu_count=1,
284271
)
285-
with pytest.raises(
286-
RuntimeError,
287-
match="Machine config error: Firecracker's huge pages support is incompatible with initrds.",
288-
):
289-
uvm_with_initrd.api.machine_config.patch(
290-
huge_pages=HugePagesConfig.HUGETLBFS_2MB
291-
)
272+
273+
uvm_with_initrd.start()
274+
serial = Serial(uvm_with_initrd)
275+
serial.open()
276+
serial.rx(token="# ")
277+
serial.tx("mount |grep rootfs")
278+
serial.rx(token=f"rootfs on / type {INITRD_FILESYSTEM}")

0 commit comments

Comments
 (0)