From 38e953778e0b9d0c36f27e5e7f4156868d2b070d Mon Sep 17 00:00:00 2001 From: tommady Date: Fri, 15 Nov 2024 21:38:03 +0000 Subject: [PATCH] eliminate the unnecessary usage of the event_manager argument eliminate the unnecessary usage of the event_manager argument Signed-off-by: tommady --- src/vmm/src/builder.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/vmm/src/builder.rs b/src/vmm/src/builder.rs index d52db6e64247..4a3eb48e0fca 100644 --- a/src/vmm/src/builder.rs +++ b/src/vmm/src/builder.rs @@ -299,7 +299,6 @@ pub mod aarch64 { pub fn create_vmm_and_vcpus( instance_info: &InstanceInfo, - event_manager: &mut EventManager, guest_memory: GuestMemoryMmap, uffd: Option, vm_config: &VmConfig, @@ -307,7 +306,6 @@ pub mod aarch64 { ) -> Result<(Vmm, Vec), StartMicrovmError> { let mut vmm = build_vmm( instance_info, - event_manager, guest_memory, uffd, vm_config, @@ -449,7 +447,6 @@ pub mod x86_64 { pub fn create_vmm_and_vcpus( instance_info: &InstanceInfo, - event_manager: &mut EventManager, guest_memory: GuestMemoryMmap, uffd: Option, vm_config: &VmConfig, @@ -457,7 +454,6 @@ pub mod x86_64 { ) -> Result<(Vmm, Vec), StartMicrovmError> { let mut vmm = build_vmm( instance_info, - event_manager, guest_memory, uffd, vm_config, @@ -473,7 +469,6 @@ pub mod x86_64 { fn build_vmm( instance_info: &InstanceInfo, - event_manager: &mut EventManager, guest_memory: GuestMemoryMmap, uffd: Option, vm_config: &VmConfig, @@ -508,7 +503,7 @@ fn build_vmm( let pio_device_manager = { // Serial device setup. let serial_device = - setup_serial_device(event_manager, std::io::stdin(), io::stdout()).map_err(Internal)?; + setup_serial_device(std::io::stdin(), io::stdout()).map_err(Internal)?; // x86_64 uses the i8042 reset event as the Vmm exit event. let reset_evt = vcpus_exit_evt @@ -583,16 +578,17 @@ pub fn build_microvm_for_boot( #[cfg(target_arch = "x86_64")] let (mut vmm, mut vcpus) = x86_64::create_vmm_and_vcpus( instance_info, - event_manager, guest_memory, None, &vm_resources.vm_config, cpu_template.kvm_capabilities.clone(), )?; + #[cfg(target_arch = "x86_64")] + event_manager.add_subscriber(vmm.pio_device_manager.stdio_serial.clone()); + #[cfg(target_arch = "aarch64")] let (mut vmm, mut vcpus) = aarch64::create_vmm_and_vcpus( instance_info, - event_manager, guest_memory, None, &vm_resources.vm_config, @@ -794,16 +790,16 @@ pub fn build_microvm_from_snapshot( #[cfg(target_arch = "x86_64")] let (mut vmm, mut vcpus) = x86_64::create_vmm_and_vcpus( instance_info, - event_manager, guest_memory.clone(), uffd, &vm_resources.vm_config, microvm_state.vm_state.kvm_cap_modifiers.clone(), )?; + #[cfg(target_arch = "x86_64")] + event_manager.add_subscriber(vmm.pio_device_manager.stdio_serial.clone()); #[cfg(target_arch = "aarch64")] let (mut vmm, mut vcpus) = aarch64::create_vmm_and_vcpus( instance_info, - event_manager, guest_memory.clone(), uffd, &vm_resources.vm_config, @@ -968,7 +964,6 @@ where /// Sets up the serial device. pub fn setup_serial_device( - event_manager: &mut EventManager, input: std::io::Stdin, out: std::io::Stdout, ) -> Result>, VmmError> { @@ -985,7 +980,7 @@ pub fn setup_serial_device( ), input: Some(input), }))); - event_manager.add_subscriber(serial.clone()); + Ok(serial) }