Skip to content

Fixed jailer build process #2125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
build to the output of `git describe --dirty`, if the git repo is available.
- MicroVM process is only attached to the cgroups defined by using `--cgroups`
or the ones defined indirectly by using `--node`.
- Changed `devtool build` to build jailer binary for `musl` only targets. Building
jailer binary for `non-musl` targets have been removed.

## [0.22.0]

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["src/firecracker", "src/jailer"]
default-members = ["src/firecracker"]

[profile.dev]
panic = "abort"
Expand Down
29 changes: 22 additions & 7 deletions tests/host_tools/cargo_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,39 @@ def get_firecracker_binaries():
building them in case they do not exist at the specified root_path.
"""
target = DEFAULT_BUILD_TARGET
cd_cmd = "cd {}".format(FC_WORKSPACE_DIR)
flags = 'RUSTFLAGS="{}"'.format(get_rustflags())
cargo_cmd = "cargo build --release --target {}".format(target)
cmd = "{} && {} {}".format(cd_cmd, flags, cargo_cmd)

utils.run_cmd(cmd)

out_dir = "{target_dir}/{target}/release".format(
target_dir=FC_WORKSPACE_TARGET_DIR, target=target
)
fc_bin_path = "{}/{}".format(out_dir, FC_BINARY_NAME)
jailer_bin_path = "{}/{}".format(out_dir, JAILER_BINARY_NAME)

if getattr(get_firecracker_binaries, 'binaries_built', False):
return fc_bin_path, jailer_bin_path

cd_cmd = "cd {}".format(FC_WORKSPACE_DIR)
flags = 'RUSTFLAGS="{}"'.format(get_rustflags())
cargo_default_cmd = "cargo build --release --target {}".format(
target
)
cargo_jailer_cmd = "cargo build -p jailer --release --target {}".format(
target
)
cmd = "{0} && {1} {2} && {1} {3}".format(
cd_cmd,
flags,
cargo_default_cmd,
cargo_jailer_cmd
)

utils.run_cmd(cmd)

utils.run_cmd(
"strip --strip-debug {} {}"
.format(fc_bin_path, jailer_bin_path)
)

setattr(get_firecracker_binaries, 'binaries_built', True)

return fc_bin_path, jailer_bin_path


Expand Down
16 changes: 16 additions & 0 deletions tools/devtool
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,22 @@ cmd_build() {
"${cargo_args[@]}"
ret=$?

[ $ret -ne 0 ] && return $ret

# Build jailer only in case of musl for compatibility reasons
if [ "$libc" == "musl" ];then
run_devctr \
--user "$(id -u):$(id -g)" \
--workdir "$CTR_FC_ROOT_DIR" \
-- \
cargo build -p jailer \
--target-dir "$CTR_CARGO_TARGET_DIR" \
"${cargo_args[@]}"

fi

ret=$?

# If `cargo build` was successful, let's copy the binaries to a more
# accessible location.
[ $ret -eq 0 ] && {
Expand Down