vmm: Handle epoll events for PTYs separately

Use two separate events for the console and serial PTY and then drive
the handling of the inputs on the PTY separately. This results in the
correct behaviour when both console and serial are attached to the PTY
as they are triggered separately on the epoll so events are not lost.

Fixes: #3012

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-08-25 12:30:49 +01:00
parent 6233f6f68e
commit 4d2a4e2805
2 changed files with 29 additions and 24 deletions

View File

@@ -148,7 +148,8 @@ pub enum EpollDispatch {
Stdin,
Api,
ActivateVirtioDevices,
Pty,
ConsolePty,
SerialPty,
}
pub struct EpollContext {
@@ -392,12 +393,12 @@ impl Vmm {
)?;
if let Some(serial_pty) = vm.serial_pty() {
self.epoll
.add_event(&serial_pty.main, EpollDispatch::Pty)
.add_event(&serial_pty.main, EpollDispatch::SerialPty)
.map_err(VmError::EventfdError)?;
};
if let Some(console_pty) = vm.console_pty() {
self.epoll
.add_event(&console_pty.main, EpollDispatch::Pty)
.add_event(&console_pty.main, EpollDispatch::ConsolePty)
.map_err(VmError::EventfdError)?;
};
self.vm = Some(vm);
@@ -1295,9 +1296,9 @@ impl Vmm {
.map_err(Error::ActivateVirtioDevices)?;
}
}
EpollDispatch::Pty => {
event @ (EpollDispatch::ConsolePty | EpollDispatch::SerialPty) => {
if let Some(ref vm) = self.vm {
vm.handle_pty().map_err(Error::Pty)?;
vm.handle_pty(event).map_err(Error::Pty)?;
}
}
EpollDispatch::Api => {