+15
-4
@@ -2,12 +2,23 @@
|
||||
//! boot (-kernel/-initrd).
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use clap::Args;
|
||||
use std::process::Command;
|
||||
|
||||
use crate::registry::registry_dir;
|
||||
|
||||
pub(crate) fn run(name: &str) -> Result<()> {
|
||||
let reg_dir = registry_dir(name)?;
|
||||
#[derive(Args, Debug)]
|
||||
pub struct RunCmd {
|
||||
/// Image tag / registry subdir name
|
||||
name: String,
|
||||
|
||||
/// Amount of memory to give the VM, in qemu's format.
|
||||
#[clap(short, long, default_value = "1024M")]
|
||||
memory: String,
|
||||
}
|
||||
|
||||
pub(crate) fn run(RunCmd { name, memory }: RunCmd) -> Result<()> {
|
||||
let reg_dir = registry_dir(&name)?;
|
||||
let vmlinuz_path = reg_dir.join("vmlinuz");
|
||||
let initrd_path = reg_dir.join("initrd");
|
||||
if !vmlinuz_path.exists() || !initrd_path.exists() {
|
||||
@@ -16,7 +27,7 @@ pub(crate) fn run(name: &str) -> Result<()> {
|
||||
name
|
||||
);
|
||||
}
|
||||
println!("Booting {} from registry: {}", name, reg_dir.display());
|
||||
println!("Booting {name} from registry: {}", reg_dir.display());
|
||||
println!(
|
||||
" qemu-system-x86_64 -m 256 -nographic -kernel {} -initrd {} -append 'console=ttyS0'",
|
||||
vmlinuz_path.display(),
|
||||
@@ -35,7 +46,7 @@ pub(crate) fn run(name: &str) -> Result<()> {
|
||||
|
||||
let mut command = Command::new("qemu-system-x86_64");
|
||||
command
|
||||
.args(["-m", "1024M"])
|
||||
.args(["-m", &memory])
|
||||
.arg("-kernel")
|
||||
.arg(vmlinuz_path.as_os_str())
|
||||
.arg("-initrd")
|
||||
|
||||
Reference in New Issue
Block a user