Skip to content

Commit 4196369

Browse files
Changed jailer build process and fixed relevant tests
This change is to make tools/devtool to build jailer binary only for musl targets. Currently, jailer binary gets built successfully for even non-musl targets but doesn't work with corresponding firecracker binary. Also modified integration build tests to build firecracker and jailer binaries only once to be used repeatitively
1 parent c5a1ceb commit 4196369

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
build to the output of `git describe --dirty`, if the git repo is available.
5050
- MicroVM process is only attached to the cgroups defined by using `--cgroups`
5151
or the ones defined indirectly by using `--node`.
52+
- Changed `devtool build` to build jailer binary for `musl` only targets. Building
53+
jailer binary for `non-musl` targets have been removed.
5254

5355
## [0.22.0]
5456

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = ["src/firecracker", "src/jailer"]
3+
default-members = ["src/firecracker"]
34

45
[profile.dev]
56
panic = "abort"

tests/host_tools/cargo_build.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,39 @@ def get_firecracker_binaries():
5656
building them in case they do not exist at the specified root_path.
5757
"""
5858
target = DEFAULT_BUILD_TARGET
59-
cd_cmd = "cd {}".format(FC_WORKSPACE_DIR)
60-
flags = 'RUSTFLAGS="{}"'.format(get_rustflags())
61-
cargo_cmd = "cargo build --release --target {}".format(target)
62-
cmd = "{} && {} {}".format(cd_cmd, flags, cargo_cmd)
63-
64-
utils.run_cmd(cmd)
65-
6659
out_dir = "{target_dir}/{target}/release".format(
6760
target_dir=FC_WORKSPACE_TARGET_DIR, target=target
6861
)
6962
fc_bin_path = "{}/{}".format(out_dir, FC_BINARY_NAME)
7063
jailer_bin_path = "{}/{}".format(out_dir, JAILER_BINARY_NAME)
7164

65+
if getattr(get_firecracker_binaries, 'binaries_built', False):
66+
return fc_bin_path, jailer_bin_path
67+
68+
cd_cmd = "cd {}".format(FC_WORKSPACE_DIR)
69+
flags = 'RUSTFLAGS="{}"'.format(get_rustflags())
70+
cargo_default_cmd = "cargo build --release --target {}".format(
71+
target
72+
)
73+
cargo_jailer_cmd = "cargo build -p jailer --release --target {}".format(
74+
target
75+
)
76+
cmd = "{0} && {1} {2} && {1} {3}".format(
77+
cd_cmd,
78+
flags,
79+
cargo_default_cmd,
80+
cargo_jailer_cmd
81+
)
82+
83+
utils.run_cmd(cmd)
84+
7285
utils.run_cmd(
7386
"strip --strip-debug {} {}"
7487
.format(fc_bin_path, jailer_bin_path)
7588
)
7689

90+
setattr(get_firecracker_binaries, 'binaries_built', True)
91+
7792
return fc_bin_path, jailer_bin_path
7893

7994

tools/devtool

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,22 @@ cmd_build() {
517517
"${cargo_args[@]}"
518518
ret=$?
519519

520+
[ $ret -ne 0 ] && return $ret
521+
522+
# Build jailer only in case of musl for compatibility reasons
523+
if [ "$libc" == "musl" ];then
524+
run_devctr \
525+
--user "$(id -u):$(id -g)" \
526+
--workdir "$CTR_FC_ROOT_DIR" \
527+
-- \
528+
cargo build -p jailer \
529+
--target-dir "$CTR_CARGO_TARGET_DIR" \
530+
"${cargo_args[@]}"
531+
532+
fi
533+
534+
ret=$?
535+
520536
# If `cargo build` was successful, let's copy the binaries to a more
521537
# accessible location.
522538
[ $ret -eq 0 ] && {

0 commit comments

Comments
 (0)