Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions crates/smolvm-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
libc = "0.2"
parking_lot = "0.12"
tempfile = "3"
regex = "1.12.3"

# Linux-specific dependencies for vsock
[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
17 changes: 17 additions & 0 deletions crates/smolvm-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fn boot_log(level: &str, msg: &str) {
}
}
mod dns_proxy;
mod name;
mod network;
mod oci;
mod paths;
Expand Down Expand Up @@ -532,6 +533,9 @@ fn setup_gpu_dev_nodes() {
}
}

#[cfg(not(target_os = "linux"))]
fn log_gpu_status() {}

/// Log whether the GPU is accessible in the guest.
///
/// Called at startup when `ENV_SMOLVM_GPU` is set. Checks whether the virtio-gpu
Expand Down Expand Up @@ -1152,6 +1156,7 @@ fn create_storage_dirs(mount_point: &str) {
}

/// Mount ext4 /dev/vda at /storage using direct syscall (avoids ~3-5ms fork+exec).
#[cfg(target_os = "linux")]
fn try_mount_storage_ext4() -> bool {
let dev = cstr("/dev/vda");
let mnt = cstr("/storage");
Expand All @@ -1168,12 +1173,19 @@ fn try_mount_storage_ext4() -> bool {
}
}

// looks like try_mount_storage is only used in mount_storage_disk, so we don't need the stub
// #[cfg(not(target_os = "linux"))]
// fn try_mount_storage_ext4() -> bool {
// false
// }

/// Mount the storage disk at /storage. Returns true if successfully mounted.
///
/// Three-attempt fallback chain:
/// 1. resize + mount (works on subsequent boots with Linux-native FS)
/// 2. fsck + resize + mount (may fix minor corruption)
/// 3. mkfs + mount (first boot from macOS template, or unrecoverable)
#[cfg(target_os = "linux")]
fn mount_storage_disk() -> bool {
use std::process::Command;

Expand Down Expand Up @@ -1276,6 +1288,11 @@ fn mount_storage_disk() -> bool {
false
}

#[cfg(not(target_os = "linux"))]
fn mount_storage_disk() -> bool {
false
}

/// Maximum number of vsock connections serviced concurrently.
/// Bounds thread count and prevents vsock channel saturation.
/// 8 (2^3) gives headroom for several parallel execs plus the state probe.
Expand Down
Loading