(
vm_config: Arc<Mutex<VmConfig>>,
exit_evt: EventFd,
reset_evt: EventFd,
guest_exit_evt: EventFd,
#[cfg(feature = "guest_debug")] vm_debug_evt: EventFd,
| 1321 | |
| 1322 | #[allow(clippy::too_many_arguments)] |
| 1323 | pub fn new( |
| 1324 | vm_config: Arc<Mutex<VmConfig>>, |
| 1325 | exit_evt: EventFd, |
| 1326 | reset_evt: EventFd, |
| 1327 | guest_exit_evt: EventFd, |
| 1328 | #[cfg(feature = "guest_debug")] vm_debug_evt: EventFd, |
| 1329 | seccomp_action: &SeccompAction, |
| 1330 | hypervisor: Arc<dyn hypervisor::Hypervisor>, |
| 1331 | activate_evt: EventFd, |
| 1332 | console_info: Option<ConsoleInfo>, |
| 1333 | console_resize_pipe: Option<Arc<File>>, |
| 1334 | original_termios: Arc<Mutex<Option<termios>>>, |
| 1335 | snapshot: Option<&Snapshot>, |
| 1336 | source_url: Option<&str>, |
| 1337 | prefault: Option<bool>, |
| 1338 | memory_restore_mode: Option<MemoryRestoreMode>, |
| 1339 | ) -> Result<Self> { |
| 1340 | trace_scoped!("Vm::new"); |
| 1341 | |
| 1342 | #[cfg(not(target_arch = "riscv64"))] |
| 1343 | let timestamp = Instant::now(); |
| 1344 | |
| 1345 | #[cfg(feature = "tdx")] |
| 1346 | let tdx_enabled = if snapshot.is_some() { |
| 1347 | false |
| 1348 | } else { |
| 1349 | vm_config.lock().unwrap().is_tdx_enabled() |
| 1350 | }; |
| 1351 | |
| 1352 | #[cfg(feature = "igvm")] |
| 1353 | let igvm_file = { |
| 1354 | let config = vm_config.lock().unwrap(); |
| 1355 | config |
| 1356 | .payload |
| 1357 | .as_ref() |
| 1358 | .and_then(|p| p.igvm.as_ref()) |
| 1359 | .map(|igvm_path| crate::igvm::parse_igvm(igvm_path)) |
| 1360 | .transpose() |
| 1361 | .map_err(Error::IgvmLoad)? |
| 1362 | }; |
| 1363 | |
| 1364 | let vm = { |
| 1365 | #[allow(unused_mut)] |
| 1366 | let mut hv_config: hypervisor::HypervisorVmConfig = |
| 1367 | vm_config.as_ref().lock().unwrap().deref().into(); |
| 1368 | #[cfg(all(feature = "igvm", feature = "sev_snp"))] |
| 1369 | if let Some(ref igvm) = igvm_file { |
| 1370 | hv_config.vmsa_features = igvm_loader::extract_sev_features(igvm); |
| 1371 | } |
| 1372 | Self::create_hypervisor_vm(hypervisor.as_ref(), hv_config)? |
| 1373 | }; |
| 1374 | |
| 1375 | #[cfg(all(feature = "kvm", target_arch = "x86_64"))] |
| 1376 | if vm_config.lock().unwrap().max_apic_id() > MAX_SUPPORTED_CPUS_LEGACY { |
| 1377 | vm.enable_x2apic_api().unwrap(); |
| 1378 | } |
| 1379 | |
| 1380 | let phys_bits = physical_bits( |
nothing calls this directly
no test coverage detected