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 <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2019-09-24 16:22:35 +02:00
parent ea7abc6c80
commit 47167a658e

View File

@ -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<RwLock<GuestMemoryMmap>> {
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)]