mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Improve naming of ConsoleInfo struct members
These aren't FDs and we don't need to know that they are the main ones. Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -67,10 +67,10 @@ pub enum ConsoleTransport {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ConsoleInfo {
|
||||
pub console_main_fd: ConsoleTransport,
|
||||
pub serial_main_fd: ConsoleTransport,
|
||||
pub console: ConsoleTransport,
|
||||
pub serial: ConsoleTransport,
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub debug_main_fd: ConsoleTransport,
|
||||
pub debug: ConsoleTransport,
|
||||
}
|
||||
|
||||
fn modify_mode<F: FnOnce(&mut termios)>(
|
||||
@@ -181,7 +181,7 @@ pub(crate) fn pre_create_console_devices(vmm: &mut Vmm) -> ConsoleDeviceResult<C
|
||||
let mut original_termios_opt = vmm.original_termios_opt.lock().unwrap();
|
||||
|
||||
let console_info = ConsoleInfo {
|
||||
console_main_fd: match vmconfig.console.mode {
|
||||
console: match vmconfig.console.mode {
|
||||
ConsoleOutputMode::File => {
|
||||
let file = File::create(vmconfig.console.file.as_ref().unwrap())
|
||||
.map_err(ConsoleDeviceError::CreateConsoleDevice)?;
|
||||
@@ -230,7 +230,7 @@ pub(crate) fn pre_create_console_devices(vmm: &mut Vmm) -> ConsoleDeviceResult<C
|
||||
ConsoleOutputMode::Null => ConsoleTransport::Null,
|
||||
ConsoleOutputMode::Off => ConsoleTransport::Off,
|
||||
},
|
||||
serial_main_fd: match vmconfig.serial.mode {
|
||||
serial: match vmconfig.serial.mode {
|
||||
ConsoleOutputMode::File => {
|
||||
let file = File::create(vmconfig.serial.file.as_ref().unwrap())
|
||||
.map_err(ConsoleDeviceError::CreateConsoleDevice)?;
|
||||
@@ -268,7 +268,7 @@ pub(crate) fn pre_create_console_devices(vmm: &mut Vmm) -> ConsoleDeviceResult<C
|
||||
ConsoleOutputMode::Off => ConsoleTransport::Off,
|
||||
},
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
debug_main_fd: match vmconfig.debug_console.mode {
|
||||
debug: match vmconfig.debug_console.mode {
|
||||
ConsoleOutputMode::File => {
|
||||
let file = File::create(vmconfig.debug_console.file.as_ref().unwrap())
|
||||
.map_err(ConsoleDeviceError::CreateConsoleDevice)?;
|
||||
|
||||
@@ -2433,7 +2433,7 @@ impl DeviceManager {
|
||||
// SAFETY: console_info is Some, so it's safe to unwrap.
|
||||
let console_info = console_info.unwrap();
|
||||
|
||||
let serial_writer: Option<Box<dyn io::Write + Send>> = match console_info.serial_main_fd {
|
||||
let serial_writer: Option<Box<dyn io::Write + Send>> = match console_info.serial {
|
||||
ConsoleTransport::File(ref file) | ConsoleTransport::Tty(ref file) => {
|
||||
Some(Box::new(Arc::clone(file)))
|
||||
}
|
||||
@@ -2443,18 +2443,15 @@ impl DeviceManager {
|
||||
| ConsoleTransport::Socket(_) => None,
|
||||
};
|
||||
|
||||
if !matches!(console_info.serial_main_fd, ConsoleTransport::Off) {
|
||||
if !matches!(console_info.serial, ConsoleTransport::Off) {
|
||||
let serial = self.add_serial_device(interrupt_manager, serial_writer)?;
|
||||
self.serial_manager = match console_info.serial_main_fd {
|
||||
self.serial_manager = match console_info.serial {
|
||||
ConsoleTransport::Pty(_)
|
||||
| ConsoleTransport::Tty(_)
|
||||
| ConsoleTransport::Socket(_) => {
|
||||
let serial_manager = SerialManager::new(
|
||||
serial,
|
||||
console_info.serial_main_fd,
|
||||
serial_config.socket,
|
||||
)
|
||||
.map_err(DeviceManagerError::CreateSerialManager)?;
|
||||
let serial_manager =
|
||||
SerialManager::new(serial, console_info.serial, serial_config.socket)
|
||||
.map_err(DeviceManagerError::CreateSerialManager)?;
|
||||
if let Some(mut serial_manager) = serial_manager {
|
||||
serial_manager
|
||||
.start_thread(
|
||||
@@ -2474,9 +2471,7 @@ impl DeviceManager {
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
let debug_console_writer: Option<Box<dyn io::Write + Send>> = match console_info
|
||||
.debug_main_fd
|
||||
{
|
||||
let debug_console_writer: Option<Box<dyn io::Write + Send>> = match console_info.debug {
|
||||
ConsoleTransport::File(file) | ConsoleTransport::Tty(file) => Some(Box::new(file)),
|
||||
ConsoleTransport::Off
|
||||
| ConsoleTransport::Null
|
||||
@@ -2489,7 +2484,7 @@ impl DeviceManager {
|
||||
}
|
||||
|
||||
let console_resizer =
|
||||
self.add_virtio_console_device(console_info.console_main_fd, console_resize_pipe)?;
|
||||
self.add_virtio_console_device(console_info.console, console_resize_pipe)?;
|
||||
|
||||
Ok(Arc::new(Console { console_resizer }))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user