From ab4635bbd24122771064ba098a144f09cc375589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Wed, 7 Aug 2024 07:33:36 -0700 Subject: [PATCH] Always capture stderr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Output of the qemu process on stderr is only captured when running in non-interactive mode. However, the error reporting infrastructure always assumes that it is being captured. As a result, we may see a panic instead of a proper error report when, for one reason or another, Qemu fails to start (as an example). Fix the issue by making sure to always capture stderr. I haven't found any adverse effects of doing so in my admittedly limited testing. Closes: #70 Signed-off-by: Daniel Müller --- src/qemu.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu.rs b/src/qemu.rs index 4ee6d6f..f9d87c7 100644 --- a/src/qemu.rs +++ b/src/qemu.rs @@ -626,6 +626,7 @@ impl Qemu { let mut c = Command::new(format!("qemu-system-{}", target.arch)); c.args(QEMU_DEFAULT_ARGS) + .stderr(Stdio::piped()) .arg("-serial") .arg("mon:stdio") .args(kvm_args(&target.arch)) @@ -698,8 +699,7 @@ impl Qemu { if !qemu.interactive() { qemu.process .stdin(Stdio::null()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); + .stdout(Stdio::piped()); } Ok(qemu) } @@ -942,7 +942,7 @@ impl Qemu { fn extract_child_stderr(child: &mut Child) -> String { let mut err = String::new(); - // unwrap() should never fail b/c we are capturing stdout + // unwrap() should never fail b/c we are capturing stderr let mut stderr = child.stderr.take().unwrap(); if let Err(e) = stderr.read_to_string(&mut err) { err += &format!("", e);