mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 21:39:26 +00:00
Merge pull request #11781 from lifupan/fupan_main_qemu
runtime-rs: log out the qemu console when debug enabled
This commit is contained in:
@@ -2410,6 +2410,10 @@ impl<'a> QemuCmdLine<'a> {
|
||||
console_socket_chardev.set_server(true);
|
||||
console_socket_chardev.set_wait(false);
|
||||
self.devices.push(Box::new(console_socket_chardev));
|
||||
|
||||
self.kernel
|
||||
.params
|
||||
.append(&mut KernelParams::from_string("console=hvc0"));
|
||||
}
|
||||
|
||||
pub fn add_virtio_balloon(&mut self) {
|
||||
|
@@ -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