vmm: Only send stdin input to serial/console if it can handle it

Do not send the contents of stdin to the serial or console device if
they're not in tty mode.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2019-08-09 11:48:03 +01:00 committed by Sebastien Boeuf
parent aa44726658
commit f910476dd7
2 changed files with 15 additions and 2 deletions

View File

@ -352,6 +352,15 @@ pub enum ConsoleOutputMode {
File, File,
} }
impl ConsoleOutputMode {
pub fn input_enabled(&self) -> bool {
match self {
ConsoleOutputMode::Tty => true,
_ => false,
}
}
}
pub struct ConsoleConfig<'a> { pub struct ConsoleConfig<'a> {
pub file: Option<&'a Path>, pub file: Option<&'a Path>,
pub mode: ConsoleOutputMode, pub mode: ConsoleOutputMode,

View File

@ -1489,7 +1489,9 @@ impl<'a> Vm<'a> {
.read_raw(&mut out) .read_raw(&mut out)
.map_err(Error::Serial)?; .map_err(Error::Serial)?;
if self.devices.serial.is_some() { if self.devices.serial.is_some()
&& self.config.serial.mode.input_enabled()
{
self.devices self.devices
.serial .serial
.as_ref() .as_ref()
@ -1500,7 +1502,9 @@ impl<'a> Vm<'a> {
.map_err(Error::Serial)?; .map_err(Error::Serial)?;
} }
if self.devices.console.is_some() { if self.devices.console.is_some()
&& self.config.console.mode.input_enabled()
{
self.devices self.devices
.console .console
.as_ref() .as_ref()