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:
parent
ea7abc6c80
commit
47167a658e
1 changed files with 18 additions and 14 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue