Skip to content

Commit 985b155

Browse files
committed
pvh: Control PVH capabilities using optional feature
Enable the optional "pvh" feature to build a Firecracker binary that is able to boot Linux guests using the PVH boot protocol. Build a firecracker binary with the PVH capability by running: tools/devtool build [--release] -- --features pvh and the resulting Firecracker binary will use the PVH boot protocol as the preferred choice for booting a guest, if the guest kernel supports it. Signed-off-by: Alejandro Jimenez <[email protected]> Acked-by: Liam Merwick <[email protected]>
1 parent 767a8f4 commit 985b155

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/firecracker/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ polly = { path = "../polly" }
1515
seccomp = { path = "../seccomp" }
1616
utils = { path = "../utils" }
1717
vmm = { path = "../vmm" }
18+
19+
[features]
20+
pvh = ["vmm/pvh"]

src/vmm/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ cpuid = { path = "../cpuid" }
2929

3030
[dev-dependencies]
3131
vmm-sys-util = ">=0.4.0"
32+
33+
[features]
34+
pvh = []

tools/devtool

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,28 @@ cmd_build() {
475475

476476
[ $profile = "release" ] && cargo_args+=("--release")
477477

478+
# Parse any optional features passed to cargo.
479+
# Currently, cargo does not support specifying features in a workspace, so passing
480+
# the "--features opt-feature" option to cargo does not enable the optional feature
481+
# in the crates that are part of the workspace, as one would expect. In order to
482+
# build the individual crates with non-default features, we can use the cargo build
483+
# option "--manifest-path", to direct cargo to use the Cargo.toml file that defines
484+
# the desired feature. The downside is that other independent crates in the workspace
485+
# (i.e. jailer) will not be built.
486+
while [ $# -gt 0 ]; do
487+
case "$1" in
488+
"--features")
489+
shift
490+
[[ "$1" =~ ^--* ]] && \
491+
die "Must specify a feature name: \"--features <opt_feature>\"."
492+
say_warn "WARNING: Building Firecracker with experimental feature." \
493+
"The jailer binary will not be built."
494+
cargo_args+=("--manifest-path" "src/firecracker/Cargo.toml")
495+
;;
496+
esac
497+
shift
498+
done
499+
478500
# Run the cargo build process inside the container.
479501
# We don't need any special privileges for the build phase, so we run the
480502
# container as the current user/group.

0 commit comments

Comments
 (0)