Merge pull request #5082 from QiliangFan/main

dragonball: Fix problem that stdio console cannot connect to stdout
This commit is contained in:
Bin Liu 2022-09-21 11:12:19 +08:00 committed by GitHub
commit a2e7434a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -74,11 +74,20 @@ impl ConsoleManager {
/// Create a console backend device by using stdio streams.
pub fn create_stdio_console(&mut self, device: Arc<Mutex<SerialDevice>>) -> Result<()> {
device
.lock()
.unwrap()
.set_output_stream(Some(Box::new(std::io::stdout())));
let stdin_handle = std::io::stdin();
stdin_handle
.lock()
.set_raw_mode()
.map_err(|e| DeviceMgrError::ConsoleManager(ConsoleManagerError::StdinHandle(e)))?;
stdin_handle
.lock()
.set_non_block(true)
.map_err(ConsoleManagerError::StdinHandle)
.map_err(DeviceMgrError::ConsoleManager)?;
let handler = ConsoleEpollHandler::new(device, Some(stdin_handle), None, &self.logger);
self.subscriber_id = Some(self.epoll_mgr.add_subscriber(Box::new(handler)));

View File

@ -591,14 +591,19 @@ impl DeviceManager {
.map_err(|_| StartMicroVmError::EventFd)?;
info!(self.logger, "init console path: {:?}", com1_sock_path);
if let Some(path) = com1_sock_path {
if let Some(legacy_manager) = self.legacy_manager.as_ref() {
if let Some(path) = com1_sock_path {
// Currently, the `com1_sock_path` "stdio" is only reserved for creating the stdio console
if path != "stdio" {
let com1 = legacy_manager.get_com1_serial();
self.con_manager
.create_socket_console(com1, path)
.map_err(StartMicroVmError::DeviceManager)?;
return Ok(());
}
} else if let Some(legacy_manager) = self.legacy_manager.as_ref() {
}
let com1 = legacy_manager.get_com1_serial();
self.con_manager
.create_stdio_console(com1)