diff --git a/arch/src/serial.rs b/arch/src/serial.rs index 9a318120a5..1062730f8b 100644 --- a/arch/src/serial.rs +++ b/arch/src/serial.rs @@ -187,7 +187,8 @@ pub fn get_serial_cmdline( .insert("console", &format!("ttyS{}", num - 1)) .map_err(GetSerialCmdlineError::KernelCmdline)?; } - Some((SerialHardware::VirtioConsole, num)) => { + Some((SerialHardware::VirtioConsole, num)) + | Some((SerialHardware::LegacyVirtioConsole, num)) => { cmdline .insert("console", &format!("hvc{}", num - 1)) .map_err(GetSerialCmdlineError::KernelCmdline)?; diff --git a/devices/src/serial_device.rs b/devices/src/serial_device.rs index dac010705f..eb4785e762 100644 --- a/devices/src/serial_device.rs +++ b/devices/src/serial_device.rs @@ -103,9 +103,10 @@ impl Display for SerialType { #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub enum SerialHardware { - Serial, // Standard PC-style (8250/16550 compatible) UART - VirtioConsole, // virtio-console device - Debugcon, // Bochs style debug port + Serial, // Standard PC-style (8250/16550 compatible) UART + VirtioConsole, // virtio-console device (AsyncConsole) + Debugcon, // Bochs style debug port + LegacyVirtioConsole, // legacy virtio-console device (Console) } impl Default for SerialHardware { @@ -120,6 +121,7 @@ impl Display for SerialHardware { SerialHardware::Serial => "serial".to_string(), SerialHardware::VirtioConsole => "virtio-console".to_string(), SerialHardware::Debugcon => "debugcon".to_string(), + SerialHardware::LegacyVirtioConsole => "legacy-virtio-console".to_string(), }; write!(f, "{}", s) diff --git a/src/crosvm/cmdline.rs b/src/crosvm/cmdline.rs index 8b21a13456..467e3018e1 100644 --- a/src/crosvm/cmdline.rs +++ b/src/crosvm/cmdline.rs @@ -1864,7 +1864,7 @@ pub struct RunCommand { /// Possible key values: /// type=(stdout,syslog,sink,file) - Where to route the /// serial device - /// hardware=(serial,virtio-console,debugcon) - Which type + /// hardware=(serial,virtio-console,debugcon,legacy-virtio-console) - Which type /// of serial hardware to emulate. Defaults to 8250 UART /// (serial). /// num=(1,2,3,4) - Serial Device Number. If not provided, diff --git a/src/crosvm/sys/unix.rs b/src/crosvm/sys/unix.rs index b0683395d6..e274d0573d 100644 --- a/src/crosvm/sys/unix.rs +++ b/src/crosvm/sys/unix.rs @@ -352,11 +352,10 @@ fn create_virtio_devices( } } - for (_, param) in cfg - .serial_parameters - .iter() - .filter(|(_k, v)| v.hardware == SerialHardware::VirtioConsole) - { + for (_, param) in cfg.serial_parameters.iter().filter(|(_k, v)| { + v.hardware == SerialHardware::VirtioConsole + || v.hardware == SerialHardware::LegacyVirtioConsole + }) { let dev = param.create_virtio_device_and_jail(cfg.protection_type, &cfg.jail_config)?; devs.push(dev); } diff --git a/src/crosvm/sys/unix/device_helpers.rs b/src/crosvm/sys/unix/device_helpers.rs index 72e9695628..74a17fe7f5 100644 --- a/src/crosvm/sys/unix/device_helpers.rs +++ b/src/crosvm/sys/unix/device_helpers.rs @@ -20,6 +20,7 @@ use anyhow::Result; use arch::VirtioDeviceStub; use base::ReadNotifier; use base::*; +use devices::serial_device::SerialHardware; use devices::serial_device::SerialParameters; use devices::serial_device::SerialType; use devices::vfio::VfioCommonSetup; @@ -45,6 +46,7 @@ use devices::virtio::vhost::user::VhostUserVsockDevice; use devices::virtio::vsock::VsockConfig; #[cfg(feature = "balloon")] use devices::virtio::BalloonMode; +use devices::virtio::Console; use devices::virtio::NetError; use devices::virtio::NetParameters; use devices::virtio::NetParametersMode; @@ -1346,10 +1348,17 @@ impl VirtioDeviceBuilder for &SerialParameters { let mut keep_rds = Vec::new(); let evt = Event::new().context("failed to create event")?; - Ok(Box::new( - self.create_serial_device::(protection_type, &evt, &mut keep_rds) - .context("failed to create console device")?, - )) + if self.hardware == SerialHardware::LegacyVirtioConsole { + Ok(Box::new( + self.create_serial_device::(protection_type, &evt, &mut keep_rds) + .context("failed to create console device")?, + )) + } else { + Ok(Box::new( + self.create_serial_device::(protection_type, &evt, &mut keep_rds) + .context("failed to create console device")?, + )) + } } fn create_vhost_user_device(