From dc723171a78997f987502ceb1596e526163721d3 Mon Sep 17 00:00:00 2001 From: Praveen K Paladugu Date: Fri, 3 May 2024 21:33:17 +0000 Subject: [PATCH] vmm: cleanup legacy console device management Signed-off-by: Praveen K Paladugu --- vmm/src/device_manager.rs | 41 ------------------------------------ vmm/src/lib.rs | 44 ++++++++++----------------------------- vmm/src/vm.rs | 32 ++-------------------------- 3 files changed, 13 insertions(+), 104 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index c80d917c2..d6fc1b94f 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -780,15 +780,6 @@ pub struct DeviceManager { // Console abstraction console: Arc, - // console PTY - console_pty: Option>>, - - // serial PTY - serial_pty: Option>>, - - // debug-console PTY - debug_console_pty: Option>>, - // Serial Manager serial_manager: Option>, @@ -1168,10 +1159,7 @@ impl DeviceManager { .map_err(DeviceManagerError::EventFd)?, acpi_address, selected_segment: 0, - serial_pty: None, serial_manager: None, - console_pty: None, - debug_console_pty: None, console_resize_pipe: None, original_termios_opt: Arc::new(Mutex::new(None)), virtio_mem_devices: Vec::new(), @@ -1204,33 +1192,12 @@ impl DeviceManager { Ok(device_manager) } - pub fn serial_pty(&self) -> Option { - self.serial_pty - .as_ref() - .map(|pty| pty.lock().unwrap().clone()) - } - - pub fn console_pty(&self) -> Option { - self.console_pty - .as_ref() - .map(|pty| pty.lock().unwrap().clone()) - } - - pub fn debug_console_pty(&self) -> Option { - self.debug_console_pty - .as_ref() - .map(|pty| pty.lock().unwrap().clone()) - } - pub fn console_resize_pipe(&self) -> Option> { self.console_resize_pipe.clone() } pub fn create_devices( &mut self, - serial_pty: Option, - console_pty: Option, - debug_console_pty: Option, console_info: Option, console_resize_pipe: Option, original_termios_opt: Arc>>, @@ -1294,9 +1261,6 @@ impl DeviceManager { self.console = self.add_console_devices( &legacy_interrupt_manager, &mut virtio_devices, - serial_pty, - console_pty, - debug_console_pty, console_info, console_resize_pipe, )?; @@ -2079,7 +2043,6 @@ impl DeviceManager { }) } - #[allow(clippy::too_many_arguments)] /// Adds all devices that behave like a console with respect to the VM /// configuration. This includes: /// - debug-console @@ -2089,10 +2052,6 @@ impl DeviceManager { &mut self, interrupt_manager: &Arc>, virtio_devices: &mut Vec, - _serial_pty: Option, - _console_pty: Option, - #[cfg(target_arch = "x86_64")] _debug_console_pty: Option, - #[cfg(not(target_arch = "x86_64"))] _: Option, console_info: Option, console_resize_pipe: Option, ) -> DeviceManagerResult> { diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index d4751efd2..c432e9576 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -811,9 +811,6 @@ impl Vmm { timestamp, None, None, - None, - None, - None, Arc::clone(&self.original_termios_opt), Some(snapshot), ) @@ -1264,9 +1261,6 @@ impl RequestHandler for Vmm { &self.seccomp_action, self.hypervisor.clone(), activate_evt, - None, - None, - None, self.console_info.clone(), None, Arc::clone(&self.original_termios_opt), @@ -1394,9 +1388,6 @@ impl RequestHandler for Vmm { &self.seccomp_action, self.hypervisor.clone(), activate_evt, - None, - None, - None, self.console_info.clone(), None, Arc::clone(&self.original_termios_opt), @@ -1443,27 +1434,17 @@ impl RequestHandler for Vmm { event!("vm", "rebooting"); // First we stop the current VM - let (config, serial_pty, console_pty, debug_console_pty, console_resize_pipe) = - if let Some(mut vm) = self.vm.take() { - let config = vm.get_config(); - let serial_pty = vm.serial_pty(); - let console_pty = vm.console_pty(); - let debug_console_pty = vm.debug_console_pty(); - let console_resize_pipe = vm - .console_resize_pipe() - .as_ref() - .map(|pipe| pipe.try_clone().unwrap()); - vm.shutdown()?; - ( - config, - serial_pty, - console_pty, - debug_console_pty, - console_resize_pipe, - ) - } else { - return Err(VmError::VmNotCreated); - }; + let (config, console_resize_pipe) = if let Some(mut vm) = self.vm.take() { + let config = vm.get_config(); + let console_resize_pipe = vm + .console_resize_pipe() + .as_ref() + .map(|pipe| pipe.try_clone().unwrap()); + vm.shutdown()?; + (config, console_resize_pipe) + } else { + return Err(VmError::VmNotCreated); + }; // vm.shutdown() closes all the console devices, so set console_info to None // so that the closed FD #s are not reused. @@ -1501,9 +1482,6 @@ impl RequestHandler for Vmm { &self.seccomp_action, self.hypervisor.clone(), activate_evt, - serial_pty, - console_pty, - debug_console_pty, self.console_info.clone(), console_resize_pipe, Arc::clone(&self.original_termios_opt), diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 2df5cc5c5..71793f7bb 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -22,7 +22,7 @@ use crate::coredump::{ CpuElf64Writable, DumpState, Elf64Writable, GuestDebuggable, GuestDebuggableError, NoteDescType, }; use crate::cpu; -use crate::device_manager::{DeviceManager, DeviceManagerError, PtyPair}; +use crate::device_manager::{DeviceManager, DeviceManagerError}; use crate::device_tree::DeviceTree; #[cfg(feature = "guest_debug")] use crate::gdb::{Debuggable, DebuggableError, GdbRequestPayload, GdbResponsePayload}; @@ -488,9 +488,6 @@ impl Vm { hypervisor: Arc, activate_evt: EventFd, timestamp: Instant, - serial_pty: Option, - console_pty: Option, - debug_console_pty: Option, console_info: Option, console_resize_pipe: Option, original_termios: Arc>>, @@ -648,14 +645,7 @@ impl Vm { device_manager .lock() .unwrap() - .create_devices( - serial_pty, - console_pty, - debug_console_pty, - console_info, - console_resize_pipe, - original_termios, - ) + .create_devices(console_info, console_resize_pipe, original_termios) .map_err(Error::DeviceManager)?; #[cfg(feature = "tdx")] @@ -806,9 +796,6 @@ impl Vm { seccomp_action: &SeccompAction, hypervisor: Arc, activate_evt: EventFd, - serial_pty: Option, - console_pty: Option, - debug_console_pty: Option, console_info: Option, console_resize_pipe: Option, original_termios: Arc>>, @@ -887,9 +874,6 @@ impl Vm { hypervisor, activate_evt, timestamp, - serial_pty, - console_pty, - debug_console_pty, console_info, console_resize_pipe, original_termios, @@ -1366,18 +1350,6 @@ impl Vm { Ok(()) } - pub fn serial_pty(&self) -> Option { - self.device_manager.lock().unwrap().serial_pty() - } - - pub fn console_pty(&self) -> Option { - self.device_manager.lock().unwrap().console_pty() - } - - pub fn debug_console_pty(&self) -> Option { - self.device_manager.lock().unwrap().debug_console_pty() - } - pub fn console_resize_pipe(&self) -> Option> { self.device_manager.lock().unwrap().console_resize_pipe() }