diff --git a/tests/src/lib.rs b/tests/src/lib.rs index ac8b7b9..e93d49d 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -63,12 +63,12 @@ fn build_and_boot( false, true, // the firmware seems to boot only on KVM false, + &["-display", "none"], )?; let mut qemu_process = qemu_command .stdin(Stdio::null()) .stdout(Stdio::piped()) .stderr(Stdio::inherit()) - .arg("-display").arg("none") .spawn()?; sleep(Duration::from_secs(5)); // TODO: kernels should probably terminate the VM qemu_process.kill()?; // there's no terminate here diff --git a/towbootctl/src/lib.rs b/towbootctl/src/lib.rs index bf74dd0..250e97c 100644 --- a/towbootctl/src/lib.rs +++ b/towbootctl/src/lib.rs @@ -113,9 +113,9 @@ pub fn create_image( } /// Boot a built image, returning the running process. -pub fn boot_image( +pub fn boot_image + std::convert::AsRef>( firmware: Option<&Path>, image: &Path, is_x86_64: bool, use_bochs: bool, - use_kvm: bool, use_gdb: bool, + use_kvm: bool, use_gdb: bool, args: &[S], ) -> Result<(Command, Vec)> { info!("getting firmware"); let firmware_path = if let Some(path) = firmware { @@ -135,6 +135,7 @@ pub fn boot_image( let config = bochsrc(&firmware_path, image, use_gdb)?.into_temp_path(); let mut bochs = Command::new("bochs"); bochs.arg("-qf").arg(config.as_os_str()); + bochs.args(args); (bochs, vec![config]) } else { info!("spawning QEMU"); @@ -154,6 +155,7 @@ pub fn boot_image( info!("The machine starts paused, waiting for GDB to attach to localhost:1234."); qemu.arg("-s").arg("-S"); } + qemu.args(args); (qemu, vec![]) }) } @@ -186,6 +188,10 @@ pub struct BootImageCommand { /// use the specified firmware instead of OVMF #[argh(option)] firmware: Option, + + /// additional arguments to pass to the hypervisor + #[argh(positional, greedy)] + args: Vec, } #[cfg(feature = "args")] @@ -193,7 +199,7 @@ impl BootImageCommand { pub fn r#do(&self) -> Result<()> { let (mut process, _temp_files) = boot_image( self.firmware.as_deref(), &self.image, self.x86_64, self.bochs, - self.kvm, self.gdb, + self.kvm, self.gdb, &self.args, )?; process.status()?.exit_ok()?; Ok(())