mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-25 02:40:04 +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::path::Path;
|
||||
use std::process::Stdio;
|
||||
use tokio::sync::{mpsc, Mutex};
|
||||
use tokio::{
|
||||
io::{AsyncBufReadExt, BufReader},
|
||||
process::{Child, ChildStderr, Command},
|
||||
};
|
||||
use tokio::{
|
||||
net::UnixStream,
|
||||
sync::{mpsc, Mutex},
|
||||
};
|
||||
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -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<()> {
|
||||
info!(sl!(), "starting reading qemu stderr");
|
||||
|
||||
|
Reference in New Issue
Block a user