mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-26 03:03:52 +00:00
runtime-rs: log out the qemu console when debug enabled
When hypervisor's debug enabled, log out the qemu's console messages for kernel boot debugging. Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This commit is contained in:
@@ -25,11 +25,14 @@ use std::cmp::Ordering;
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use tokio::sync::{mpsc, Mutex};
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
io::{AsyncBufReadExt, BufReader},
|
io::{AsyncBufReadExt, BufReader},
|
||||||
process::{Child, ChildStderr, Command},
|
process::{Child, ChildStderr, Command},
|
||||||
};
|
};
|
||||||
|
use tokio::{
|
||||||
|
net::UnixStream,
|
||||||
|
sync::{mpsc, Mutex},
|
||||||
|
};
|
||||||
|
|
||||||
const VSOCK_SCHEME: &str = "vsock";
|
const VSOCK_SCHEME: &str = "vsock";
|
||||||
|
|
||||||
@@ -223,6 +226,12 @@ impl QemuInner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//When hypervisor debug is enabled, output the kernel boot messages for debugging.
|
||||||
|
if self.config.debug_info.enable_debug {
|
||||||
|
let stream = UnixStream::connect(console_socket_path.as_os_str()).await?;
|
||||||
|
tokio::spawn(log_qemu_console(stream));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,6 +578,24 @@ impl QemuInner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn log_qemu_console(console: UnixStream) -> Result<()> {
|
||||||
|
info!(sl!(), "starting reading qemu console");
|
||||||
|
|
||||||
|
let stderr_reader = BufReader::new(console);
|
||||||
|
let mut stderr_lines = stderr_reader.lines();
|
||||||
|
|
||||||
|
while let Some(buffer) = stderr_lines
|
||||||
|
.next_line()
|
||||||
|
.await
|
||||||
|
.context("next_line() failed on qemu console")?
|
||||||
|
{
|
||||||
|
info!(sl!(), "vm console: {:?}", buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
info!(sl!(), "finished reading qemu console");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn log_qemu_stderr(stderr: ChildStderr, exit_notify: mpsc::Sender<()>) -> Result<()> {
|
async fn log_qemu_stderr(stderr: ChildStderr, exit_notify: mpsc::Sender<()>) -> Result<()> {
|
||||||
info!(sl!(), "starting reading qemu stderr");
|
info!(sl!(), "starting reading qemu stderr");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user