mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Refactor serial buffer to allow flush on PTY when writable
Refactor the serial buffer handling in order to write the serial buffer's output to a PTY connected after the serial device stops being written to by the guest. This change moves the serial buffer initialization inside the serial manager. That is done to allow the serial buffer to be made aware of the PTY and epoll fds needed in order to modify the EpollDispatch::File trigger. These are then used by the serial buffer to trigger an epoll event when the PTY fd is writable and the buffer has content in it. They are also used to remove the trigger when the buffer is emptied in order to avoid unnecessary wake-ups. Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
0066ddefe1
commit
a8f063db7c
@@ -23,7 +23,6 @@ use crate::interrupt::LegacyUserspaceInterruptManager;
|
||||
use crate::memory_manager::MEMORY_MANAGER_ACPI_SIZE;
|
||||
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use crate::serial_buffer::SerialBuffer;
|
||||
use crate::serial_manager::{Error as SerialManagerError, SerialManager};
|
||||
use crate::sigwinch_listener::start_sigwinch_listener;
|
||||
use crate::GuestRegionMmap;
|
||||
@@ -1818,21 +1817,16 @@ impl DeviceManager {
|
||||
ConsoleOutputMode::Pty => {
|
||||
if let Some(pty) = serial_pty {
|
||||
self.config.lock().unwrap().serial.file = Some(pty.path.clone());
|
||||
let writer = pty.main.try_clone().unwrap();
|
||||
let buffer = SerialBuffer::new(Box::new(writer));
|
||||
self.serial_pty = Some(Arc::new(Mutex::new(pty)));
|
||||
Some(Box::new(buffer))
|
||||
} else {
|
||||
let (main, mut sub, path) =
|
||||
create_pty(true).map_err(DeviceManagerError::SerialPtyOpen)?;
|
||||
self.set_raw_mode(&mut sub)
|
||||
.map_err(DeviceManagerError::SetPtyRaw)?;
|
||||
self.config.lock().unwrap().serial.file = Some(path.clone());
|
||||
let writer = main.try_clone().unwrap();
|
||||
let buffer = SerialBuffer::new(Box::new(writer));
|
||||
self.serial_pty = Some(Arc::new(Mutex::new(PtyPair { main, sub, path })));
|
||||
Some(Box::new(buffer))
|
||||
}
|
||||
None
|
||||
}
|
||||
ConsoleOutputMode::Tty => Some(Box::new(stdout())),
|
||||
ConsoleOutputMode::Off | ConsoleOutputMode::Null => None,
|
||||
|
||||
Reference in New Issue
Block a user