hypha: implement console support

This commit is contained in:
Alex Zenla
2024-01-21 04:49:31 -08:00
parent ece88e16cc
commit d9629f46d0
5 changed files with 103 additions and 21 deletions

View File

@ -6,12 +6,6 @@ use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(version, about)]
struct ControllerArgs {
#[arg(short, long)]
kernel: String,
#[arg(short = 'r', long)]
initrd: String,
#[arg(short, long, default_value = "auto")]
store: String,
@ -22,6 +16,10 @@ struct ControllerArgs {
#[derive(Subcommand, Debug)]
enum Commands {
Launch {
#[arg(short, long)]
kernel: String,
#[arg(short = 'r', long)]
initrd: String,
#[arg(short, long)]
image: String,
#[arg(short, long, default_value_t = 1)]
@ -33,6 +31,10 @@ enum Commands {
#[arg(short, long)]
domain: u32,
},
Console {
#[arg(short, long)]
domain: u32,
},
}
fn main() -> Result<()> {
@ -51,16 +53,27 @@ fn main() -> Result<()> {
.map(|x| x.to_string())
.ok_or_else(|| HyphaError::new("unable to convert store path to string"))?;
let mut controller = Controller::new(store_path, args.kernel, args.initrd)?;
let mut controller = Controller::new(store_path)?;
match args.command {
Commands::Launch { image, cpus, mem } => {
let domid = controller.launch(image.as_str(), cpus, mem)?;
Commands::Launch {
kernel,
initrd,
image,
cpus,
mem,
} => {
let domid = controller.launch(&kernel, &initrd, &image, cpus, mem)?;
println!("launched domain: {}", domid);
}
Commands::Destroy { domain } => {
controller.destroy(domain)?;
}
Commands::Console { domain } => {
controller.console(domain)?;
}
}
Ok(())
}