Skip to content

Commit

Permalink
Merge pull request #4175 from systeminit/fix/deps
Browse files Browse the repository at this point in the history
fix: cfg out linux-only firecracker dependencies
  • Loading branch information
sprutton1 authored Jul 19, 2024
2 parents 392282f + a86fbcd commit 70db947
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
ripgrep
rust-toolchain
minica
lvm2
llvmPackages.libclang.lib

# breakpointHook
]
Expand All @@ -68,6 +66,8 @@
++ lib.optionals pkgs.stdenv.isLinux [
glibc
glibc.libgcc
lvm2
llvmPackages.libclang.lib
]
++ lib.optionals pkgs.stdenv.isDarwin [
libiconv
Expand Down
10 changes: 7 additions & 3 deletions lib/si-firecracker/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ rust_library(
name = "si-firecracker",
deps = [
"//lib/cyclone-core:cyclone-core",
"//third-party/rust:devicemapper",
"//third-party/rust:krata-loopdev",
"//third-party/rust:remain",
"//third-party/rust:nix",
"//third-party/rust:thiserror",
"//third-party/rust:tokio",
"//third-party/rust:tracing",
],
] + select({
"DEFAULT": [],
"config//os:linux": [
"//third-party/rust:krata-loopdev",
"//third-party/rust:devicemapper",
],
}),
srcs = glob(["src/**/*.rs","src/scripts/*"]),
)

Expand Down
6 changes: 4 additions & 2 deletions lib/si-firecracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ publish.workspace = true

[dependencies]
cyclone-core = { path = "../cyclone-core" }
devicemapper = { workspace = true }
futures = { workspace = true }
krata-loopdev = { workspace = true }
nix = { workspace = true }
remain = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }

[dev-dependencies]

[target.'cfg(target_os = "linux")'.dependencies]
devicemapper = { workspace = true }
krata-loopdev = { workspace = true }
1 change: 1 addition & 0 deletions lib/si-firecracker/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub enum FirecrackerJailError {
#[error("Failed to clean a jail: {0}")]
Clean(#[source] tokio::io::Error),
// Error from DmSetup
#[cfg(target_os = "linux")]
#[error("dmsetup error: {0}")]
DmSetup(#[from] devicemapper::DmError),
// Failed to interact with a mount
Expand Down
3 changes: 3 additions & 0 deletions lib/si-firecracker/src/firecracker.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(target_os = "linux")]
use crate::disk::FirecrackerDisk;
use crate::errors::FirecrackerJailError;
use cyclone_core::process;
Expand Down Expand Up @@ -61,6 +62,8 @@ impl FirecrackerJail {
}

pub async fn clean(id: u32) -> Result<()> {
let _ = id;
#[cfg(target_os = "linux")]
FirecrackerDisk::clean(id)?;
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions lib/si-firecracker/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(target_os = "linux")]
mod disk;
/// [`FirecrackerJailError`] implementations.
pub mod errors;
Expand Down
2 changes: 1 addition & 1 deletion prelude-si/rootfs/rootfs_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ setup_traps cleanup

# create disk and mount to a known location
mkdir -pv "$ROOTFSMOUNT"
dd if=/dev/zero of="$ROOTFS" bs=1M count=2048
dd if=/dev/zero of="$ROOTFS" bs=1M count=3072
mkfs.ext4 -v "$ROOTFS"
sudo mount -v "$ROOTFS" "$ROOTFSMOUNT"

Expand Down

0 comments on commit 70db947

Please sign in to comment.