Skip to content

Commit

Permalink
Adds AArch64 specific arguments for QEMU
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon committed Aug 26, 2023
1 parent 40b4f2f commit 71d6c5e
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions testing/src/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ fn run_test(root: &Path, target: &str, config: &QemuConfig) {
std::fs::copy(&config.nvram, &nvram)
.unwrap_or_else(|e| panic!("cannot copy {} to {}: {}", config.nvram, vm.display(), e));

// Spawn QEMU.
let mut qemu = Command::new(&config.bin)
.stdin(Stdio::null())
// Setup QEMU common arguments.
let mut qemu = Command::new(&config.bin);

qemu.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::null())
.arg("-nographic")
Expand All @@ -194,20 +195,31 @@ fn run_test(root: &Path, target: &str, config: &QemuConfig) {
.arg(format!(
"if=virtio,format=raw,file={}",
disk.to_str().unwrap()
))
));

if target == "aarch64-unknown-uefi" {
qemu.args(["-machine", "virt"]);
qemu.args(["-cpu", "cortex-a57"]);
}

// Spawn QEMU.
let mut qemu = qemu
.spawn()
.unwrap_or_else(|e| panic!("cannot spawn {}: {}", config.bin, e));

// Associate QEMU to a panic handler so it will get killed if panic=abort.
let mut stdout = BufReader::new(qemu.stdout.take().unwrap());
let qemu = Arc::new(Mutex::new(Some(Process(qemu))));
let hook = std::panic::take_hook();
let qemu_copy = qemu.clone();

std::panic::set_hook(Box::new(move |i| {
*qemu_copy.lock().unwrap() = None;
hook(i);
}));
{
let qemu = qemu.clone();

std::panic::set_hook(Box::new(move |i| {
*qemu.lock().unwrap() = None;
hook(i);
}));
}

// Read our command.
let mut line = String::new();
Expand Down

0 comments on commit 71d6c5e

Please sign in to comment.