Skip to content

Commit

Permalink
Merge pull request #32 from OSInside/make_sure_proc_mountpoint_exists
Browse files Browse the repository at this point in the history
Make sure system mount point exists for sci
  • Loading branch information
schaefi authored Jan 15, 2024
2 parents 2d3336c + cc75b6b commit 8f64b99
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
1 change: 0 additions & 1 deletion firecracker-pilot/guestvm-tools/sci/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub const PROBE_MODULE: &str = "/sbin/modprobe";
pub const SYSTEMD_NETWORK_RESOLV_CONF: &str = "/run/systemd/resolve/resolv.conf";
pub const VM_QUIT: &str = "sci_quit";
pub const VHOST_TRANSPORT: &str = "vmw_vsock_virtio_transport";
pub const SOCAT: &str = "/usr/bin/socat";
pub const VM_PORT: u32 = 52;
pub const GUEST_CID: u32 = 3;

Expand Down
2 changes: 1 addition & 1 deletion firecracker-pilot/guestvm-tools/sci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fn main() {
defaults::OVERLAY_UPPER, defaults::OVERLAY_WORK
)
)
.mount("overlay", "/overlayroot/rootfs")
.mount("overlay", defaults::OVERLAY_ROOT)
{
Ok(_) => {
debug(&format!(
Expand Down
4 changes: 0 additions & 4 deletions firecracker-pilot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ fn main() -> ExitCode {

let result = run();

// TODO: implement cleanup function
// cleanup()

match result {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
Expand All @@ -60,7 +57,6 @@ fn main() -> ExitCode {
}

fn run() -> Result<(), FlakeError> {

let program_path = app_path::program_abs_path();
let program_name = app_path::basename(&program_path);

Expand Down
32 changes: 32 additions & 0 deletions flake-ctl/src/firecracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,25 @@ pub async fn pull_component_image(
let sci_in_image = format!(
"{}/{}", tmp_dir_path, "/usr/sbin/sci"
);
// required for overlay mount process
let overlay_root_in_image = format!(
"{}/{}", tmp_dir_path, "/overlayroot"
);
// required for /proc/sys/kernel/sysrq based force_reboot
let proc_in_image = format!(
"{}/{}", tmp_dir_path, "/proc"
);
// required for pivot
let sys_in_image = format!(
"{}/{}", tmp_dir_path, "/sys"
);
let dev_in_image = format!(
"{}/{}", tmp_dir_path, "/dev"
);
// required for PTS allocation
let dev_pts_in_image = format!(
"{}/{}", tmp_dir_path, "/dev/pts"
);
if ! Path::new(&sci_in_image).exists() {
info!("Copying sci to rootfs...");
if ! copy(
Expand All @@ -187,6 +203,22 @@ pub async fn pull_component_image(
umount(&tmp_dir_path, "root");
return result
}
if ! Path::new(&proc_in_image).exists() && ! mkdir(&proc_in_image, "root") {
umount(&tmp_dir_path, "root");
return result
}
if ! Path::new(&sys_in_image).exists() && ! mkdir(&sys_in_image, "root") {
umount(&tmp_dir_path, "root");
return result
}
if ! Path::new(&dev_in_image).exists() && ! mkdir(&dev_in_image, "root") {
umount(&tmp_dir_path, "root");
return result
}
if ! Path::new(&dev_pts_in_image).exists() && ! mkdir(&dev_pts_in_image, "root") {
umount(&tmp_dir_path, "root");
return result
}
umount(&tmp_dir_path, "root");
}

Expand Down

0 comments on commit 8f64b99

Please sign in to comment.