implement squashfs generation

This commit is contained in:
Alex Zenla
2024-01-17 14:29:05 -08:00
parent f69ce96054
commit 198ca3ff80
8 changed files with 243 additions and 35 deletions

View File

@ -1,27 +0,0 @@
use clap::Parser;
use hypha::agent::Agent;
use hypha::error::Result;
#[derive(Parser, Debug)]
#[command(version, about)]
struct AgentArgs {
#[arg(short, long)]
kernel: String,
#[arg(short, long)]
initrd: String,
#[arg(short, long, default_value_t = 1)]
cpus: u32,
#[arg(short, long, default_value_t = 512)]
mem: u64,
}
fn main() -> Result<()> {
let args = AgentArgs::parse();
let mut agent = Agent::new(args.kernel, args.initrd, args.cpus, args.mem)?;
let domid = agent.launch()?;
println!("launched domain: {}", domid);
Ok(())
}

View File

@ -1,5 +1,7 @@
use hypha::error::Result;
fn main() -> Result<()> {
env_logger::init();
Ok(())
}

39
hypha/bin/controller.rs Normal file
View File

@ -0,0 +1,39 @@
use clap::Parser;
use hypha::ctl::Controller;
use hypha::error::Result;
use hypha::image::ImageCompiler;
use ocipkg::ImageName;
#[derive(Parser, Debug)]
#[command(version, about)]
struct ControllerArgs {
#[arg(short, long)]
kernel: String,
#[arg(short = 'r', long)]
initrd: String,
#[arg(short, long)]
image: String,
#[arg(short, long, default_value_t = 1)]
cpus: u32,
#[arg(short, long, default_value_t = 512)]
mem: u64,
}
fn main() -> Result<()> {
env_logger::init();
let args = ControllerArgs::parse();
let mut controller = Controller::new(args.kernel, args.initrd, args.cpus, args.mem)?;
let image = ImageName::parse(args.image.as_str())?;
let compiler = ImageCompiler::new()?;
let squashfs = compiler.compile(&image)?;
println!("packed image into squashfs: {}", &squashfs);
let domid = controller.launch()?;
println!("launched domain: {}", domid);
Ok(())
}