From 47167a658e1682d8f29d063c84e2c9f290eb84e2 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 24 Sep 2019 16:22:35 +0200 Subject: [PATCH] vmm: Add a VM console handling method In order to handle the VM STDIN stream from a separate VMM thread without having to export the DeviceManager, we simply add a console handling method to the Vm structure. Signed-off-by: Samuel Ortiz --- vmm/src/vm.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index f6989be3a..cf7027903 100755 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -890,20 +890,7 @@ impl Vm { break 'outer; } - EpollDispatch::Stdin => { - let mut out = [0u8; 64]; - let count = io::stdin() - .lock() - .read_raw(&mut out) - .map_err(Error::Console)?; - - if self.devices.console().input_enabled() { - self.devices - .console() - .queue_input_bytes(&out[..count]) - .map_err(Error::Console)?; - } - } + EpollDispatch::Stdin => self.handle_stdin()?, } } } @@ -1057,6 +1044,23 @@ impl Vm { pub fn get_memory(&self) -> Arc> { self.memory.clone() } + + pub fn handle_stdin(&self) -> Result<()> { + let mut out = [0u8; 64]; + let count = io::stdin() + .lock() + .read_raw(&mut out) + .map_err(Error::Console)?; + + if self.devices.console().input_enabled() { + self.devices + .console() + .queue_input_bytes(&out[..count]) + .map_err(Error::Console)?; + } + + Ok(()) + } } #[allow(unused)]