mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
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
@ -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…
Reference in New Issue
Block a user