Skip to content

Commit 8dbe982

Browse files
author
Roy Lin
committed
fix(box): gate split-console (raw fds) to Unix — Windows build
The split-console path used std::os::unix::io::AsRawFd / as_raw_fd, which don't exist on Windows, breaking the v2.0.7 Windows build (E0433/E0599) — so the release aborted before publishing (nothing was published). Gate the split path to #[cfg(unix)]; Windows always uses the merged single-file console (set_console_output), same as before. Unix behavior unchanged.
1 parent 46c7b2d commit 8dbe982

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

src/shim/src/main.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -759,33 +759,30 @@ unsafe fn configure_and_start_vm(spec: &InstanceSpec) -> Result<()> {
759759
// Split console: guest stdout -> console.log, stderr -> console.err.log
760760
// (libkrun's 3-fd virtio-console separates the streams), so the log
761761
// processor can tag each line's stream like Docker's json-file driver.
762-
// Falls back to the merged single-file console if the err file can't be
763-
// opened. BOX_NO_SPLIT_STDERR forces the legacy merged behavior.
764-
use std::os::unix::io::AsRawFd;
765-
let opened = if std::env::var_os("BOX_NO_SPLIT_STDERR").is_none() {
762+
// Unix only (uses raw fds); Windows always uses the merged single-file
763+
// console. Falls back to merged if the err file can't be opened, and
764+
// BOX_NO_SPLIT_STDERR forces the legacy merged behavior.
765+
#[allow(unused_mut)]
766+
let mut split_done = false;
767+
#[cfg(unix)]
768+
if std::env::var_os("BOX_NO_SPLIT_STDERR").is_none() {
769+
use std::os::unix::io::AsRawFd;
766770
let err_path = console_path.with_file_name("console.err.log");
767771
let open = |p: &std::path::Path| {
768772
std::fs::OpenOptions::new().create(true).append(true).open(p)
769773
};
770-
match (open(console_path), open(&err_path)) {
771-
(Ok(out_f), Ok(err_f)) => Some((out_f, err_f)),
772-
_ => None,
773-
}
774-
} else {
775-
None
776-
};
777-
match opened {
778-
Some((out_f, err_f)) => {
774+
if let (Ok(out_f), Ok(err_f)) = (open(console_path), open(&err_path)) {
779775
ctx.add_split_console(-1, out_f.as_raw_fd(), err_f.as_raw_fd())?;
780776
// Keep the fds open for the VM's lifetime.
781777
std::mem::forget(out_f);
782778
std::mem::forget(err_f);
783779
tracing::debug!("split console enabled (stdout/stderr separated)");
780+
split_done = true;
784781
}
785-
None => {
786-
tracing::debug!(console_path = console_str, "Redirecting console output (merged)");
787-
ctx.set_console_output(console_str)?;
788-
}
782+
}
783+
if !split_done {
784+
tracing::debug!(console_path = console_str, "Redirecting console output (merged)");
785+
ctx.set_console_output(console_str)?;
789786
}
790787
}
791788

0 commit comments

Comments
 (0)