MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / new_from_memory_manager

Method new_from_memory_manager

vmm/src/vm.rs:563–722  ·  view source on GitHub ↗
(
        config: Arc<Mutex<VmConfig>>,
        memory_manager: Arc<Mutex<MemoryManager>>,
        vm: Arc<dyn hypervisor::Vm>,
        exit_evt: EventFd,
        reset_evt: EventFd,
        guest_exi

Source from the content-addressed store, hash-verified

561 #[allow(clippy::needless_pass_by_value)]
562 #[allow(clippy::too_many_arguments)]
563 pub fn new_from_memory_manager(
564 config: Arc<Mutex<VmConfig>>,
565 memory_manager: Arc<Mutex<MemoryManager>>,
566 vm: Arc<dyn hypervisor::Vm>,
567 exit_evt: EventFd,
568 reset_evt: EventFd,
569 guest_exit_evt: EventFd,
570 #[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
571 seccomp_action: &SeccompAction,
572 hypervisor: Arc<dyn hypervisor::Hypervisor>,
573 activate_evt: EventFd,
574 #[cfg(not(target_arch = "riscv64"))] timestamp: Instant,
575 console_info: Option<ConsoleInfo>,
576 console_resize_pipe: Option<Arc<File>>,
577 original_termios: Arc<Mutex<Option<termios>>>,
578 snapshot: Option<&Snapshot>,
579 #[cfg(feature = "igvm")] igvm_file: Option<IgvmFile>,
580 ) -> Result<Self> {
581 trace_scoped!("Vm::new_from_memory_manager");
582
583 let boot_id_list = config
584 .lock()
585 .unwrap()
586 .validate()
587 .map_err(Error::ConfigValidation)?;
588
589 info!("Booting VM from config: {:?}", &config);
590
591 // Create NUMA nodes based on NumaConfig.
592 let numa_nodes =
593 Self::create_numa_nodes(config.lock().unwrap().numa.as_deref(), &memory_manager)?;
594
595 // Determine if VIRTIO_F_ACCESS_PLATFORM should be forced (e.g. for TDX/SEV-SNP)
596 let force_access_platform = Self::should_force_access_platform(&config);
597
598 let stop_on_boot = Self::should_stop_on_boot(&config);
599
600 let memory = memory_manager.lock().unwrap().guest_memory();
601 let io_bus = Arc::new(Bus::new());
602 let mmio_bus = Arc::new(Bus::new());
603
604 let vm_ops: Arc<dyn VmOps> = Arc::new(VmOpsHandler {
605 memory,
606 #[cfg(target_arch = "x86_64")]
607 io_bus: io_bus.clone(),
608 mmio_bus: mmio_bus.clone(),
609 });
610
611 // Create CPU manager
612 let cpu_manager = Self::create_cpu_manager(
613 &config,
614 vm.clone(),
615 exit_evt.try_clone().map_err(Error::EventFdClone)?,
616 reset_evt.try_clone().map_err(Error::EventFdClone)?,
617 #[cfg(feature = "guest_debug")]
618 vm_debug_evt,
619 &hypervisor,
620 seccomp_action.clone(),

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
get_vm_snapshotFunction · 0.85
validateMethod · 0.45
guest_memoryMethod · 0.45
cloneMethod · 0.45
try_cloneMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected