Skip to content

Commit 42a8acc

Browse files
committed
Show QEMU error message on boot failure
Before the actual QEMU error message was swallowed up and hidden. This makes troubleshooting quite difficult. Display the true error.
1 parent b84f56b commit 42a8acc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/qemu.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,18 @@ impl Qemu {
664664
let qmp_info = match qmp.handshake() {
665665
Ok(i) => i,
666666
Err(e) => {
667-
let _ = self
668-
.updates
669-
.send(Output::BootEnd(Err(e).context("QMP handshake failed")));
667+
// If the handshake failed, grab stderr from qemu and display it
668+
// to assist with debugging
669+
let mut err = String::new();
670+
// unwrap() should never fail b/c we are capturing stdout
671+
let mut stderr = child.stderr.take().unwrap();
672+
if let Err(e) = stderr.read_to_string(&mut err) {
673+
err += &format!("<failed to read stderr: {}>", e);
674+
}
675+
676+
let _ = self.updates.send(Output::BootEnd(
677+
Err(e).context("QMP handshake failed").context(err),
678+
));
670679
return;
671680
}
672681
};

0 commit comments

Comments
 (0)