Skip to content

Commit 38e9537

Browse files
committed
eliminate the unnecessary usage of the event_manager argument
eliminate the unnecessary usage of the event_manager argument Signed-off-by: tommady <[email protected]>
1 parent fe18c9e commit 38e9537

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/vmm/src/builder.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,13 @@ pub mod aarch64 {
299299

300300
pub fn create_vmm_and_vcpus(
301301
instance_info: &InstanceInfo,
302-
event_manager: &mut EventManager,
303302
guest_memory: GuestMemoryMmap,
304303
uffd: Option<Uffd>,
305304
vm_config: &VmConfig,
306305
kvm_capabilities: Vec<KvmCapability>,
307306
) -> Result<(Vmm, Vec<Vcpu>), StartMicrovmError> {
308307
let mut vmm = build_vmm(
309308
instance_info,
310-
event_manager,
311309
guest_memory,
312310
uffd,
313311
vm_config,
@@ -449,15 +447,13 @@ pub mod x86_64 {
449447

450448
pub fn create_vmm_and_vcpus(
451449
instance_info: &InstanceInfo,
452-
event_manager: &mut EventManager,
453450
guest_memory: GuestMemoryMmap,
454451
uffd: Option<Uffd>,
455452
vm_config: &VmConfig,
456453
kvm_capabilities: Vec<KvmCapability>,
457454
) -> Result<(Vmm, Vec<Vcpu>), StartMicrovmError> {
458455
let mut vmm = build_vmm(
459456
instance_info,
460-
event_manager,
461457
guest_memory,
462458
uffd,
463459
vm_config,
@@ -473,7 +469,6 @@ pub mod x86_64 {
473469

474470
fn build_vmm(
475471
instance_info: &InstanceInfo,
476-
event_manager: &mut EventManager,
477472
guest_memory: GuestMemoryMmap,
478473
uffd: Option<Uffd>,
479474
vm_config: &VmConfig,
@@ -508,7 +503,7 @@ fn build_vmm(
508503
let pio_device_manager = {
509504
// Serial device setup.
510505
let serial_device =
511-
setup_serial_device(event_manager, std::io::stdin(), io::stdout()).map_err(Internal)?;
506+
setup_serial_device(std::io::stdin(), io::stdout()).map_err(Internal)?;
512507

513508
// x86_64 uses the i8042 reset event as the Vmm exit event.
514509
let reset_evt = vcpus_exit_evt
@@ -583,16 +578,17 @@ pub fn build_microvm_for_boot(
583578
#[cfg(target_arch = "x86_64")]
584579
let (mut vmm, mut vcpus) = x86_64::create_vmm_and_vcpus(
585580
instance_info,
586-
event_manager,
587581
guest_memory,
588582
None,
589583
&vm_resources.vm_config,
590584
cpu_template.kvm_capabilities.clone(),
591585
)?;
586+
#[cfg(target_arch = "x86_64")]
587+
event_manager.add_subscriber(vmm.pio_device_manager.stdio_serial.clone());
588+
592589
#[cfg(target_arch = "aarch64")]
593590
let (mut vmm, mut vcpus) = aarch64::create_vmm_and_vcpus(
594591
instance_info,
595-
event_manager,
596592
guest_memory,
597593
None,
598594
&vm_resources.vm_config,
@@ -794,16 +790,16 @@ pub fn build_microvm_from_snapshot(
794790
#[cfg(target_arch = "x86_64")]
795791
let (mut vmm, mut vcpus) = x86_64::create_vmm_and_vcpus(
796792
instance_info,
797-
event_manager,
798793
guest_memory.clone(),
799794
uffd,
800795
&vm_resources.vm_config,
801796
microvm_state.vm_state.kvm_cap_modifiers.clone(),
802797
)?;
798+
#[cfg(target_arch = "x86_64")]
799+
event_manager.add_subscriber(vmm.pio_device_manager.stdio_serial.clone());
803800
#[cfg(target_arch = "aarch64")]
804801
let (mut vmm, mut vcpus) = aarch64::create_vmm_and_vcpus(
805802
instance_info,
806-
event_manager,
807803
guest_memory.clone(),
808804
uffd,
809805
&vm_resources.vm_config,
@@ -968,7 +964,6 @@ where
968964

969965
/// Sets up the serial device.
970966
pub fn setup_serial_device(
971-
event_manager: &mut EventManager,
972967
input: std::io::Stdin,
973968
out: std::io::Stdout,
974969
) -> Result<Arc<Mutex<BusDevice>>, VmmError> {
@@ -985,7 +980,7 @@ pub fn setup_serial_device(
985980
),
986981
input: Some(input),
987982
})));
988-
event_manager.add_subscriber(serial.clone());
983+
989984
Ok(serial)
990985
}
991986

0 commit comments

Comments
 (0)