mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
crosvm: Add flag to use legacy console
Some downstreams currently still use the legacy console. Some e2e_tests (snapshot/restore) also will require using the legacy console, as the AsyncConsole does not currently have an implementation for these functions. BUG=N/A TEST=presubmit TEST=run VM with legacy console flag Change-Id: I97f94d79c6b0c2c23115283e1539f7cda580f5b8 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4618965 Reviewed-by: Noah Gold <nkgold@google.com> Reviewed-by: Frederick Mayle <fmayle@google.com> Commit-Queue: Elie Kheirallah <khei@google.com>
This commit is contained in:
parent
a3b2739c0b
commit
e8705e87f0
5 changed files with 25 additions and 14 deletions
|
@ -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)?;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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::<AsyncConsole>(protection_type, &evt, &mut keep_rds)
|
||||
.context("failed to create console device")?,
|
||||
))
|
||||
if self.hardware == SerialHardware::LegacyVirtioConsole {
|
||||
Ok(Box::new(
|
||||
self.create_serial_device::<Console>(protection_type, &evt, &mut keep_rds)
|
||||
.context("failed to create console device")?,
|
||||
))
|
||||
} else {
|
||||
Ok(Box::new(
|
||||
self.create_serial_device::<AsyncConsole>(protection_type, &evt, &mut keep_rds)
|
||||
.context("failed to create console device")?,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn create_vhost_user_device(
|
||||
|
|
Loading…
Reference in a new issue