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

Method configure_vcpu

vmm/src/cpu.rs:1009–1069  ·  view source on GitHub ↗
(
        &self,
        vcpu: &mut Vcpu,
        boot_setup: Option<(EntryPoint, &GuestMemoryAtomic<GuestMemoryMmap>)>,
    )

Source from the content-addressed store, hash-verified

1007 }
1008
1009 pub fn configure_vcpu(
1010 &self,
1011 vcpu: &mut Vcpu,
1012 boot_setup: Option<(EntryPoint, &GuestMemoryAtomic<GuestMemoryMmap>)>,
1013 ) -> Result<()> {
1014 #[cfg(all(feature = "sev_snp", feature = "mshv"))]
1015 if self.sev_snp_enabled
1016 && self.hypervisor.hypervisor_type() == hypervisor::HypervisorType::Mshv
1017 {
1018 if let Some((kernel_entry_point, _)) = boot_setup {
1019 vcpu.set_sev_control_register(
1020 kernel_entry_point.entry_addr.0 / crate::igvm::HV_PAGE_SIZE,
1021 )?;
1022 }
1023
1024 // Traditional way to configure vcpu doesn't work for SEV-SNP guests.
1025 // All the vCPU configuration for SEV-SNP guest is provided via VMSA.
1026 return Ok(());
1027 }
1028
1029 #[cfg(target_arch = "x86_64")]
1030 assert!(!self.cpuid.is_empty());
1031
1032 #[cfg(target_arch = "x86_64")]
1033 let topology = self.config.topology.clone().map_or_else(
1034 || {
1035 (
1036 1_u16,
1037 u16::try_from(self.boot_vcpus()).unwrap(),
1038 1_u16,
1039 1_u16,
1040 )
1041 },
1042 |t| {
1043 (
1044 t.threads_per_core,
1045 t.cores_per_die,
1046 t.dies_per_package,
1047 t.packages,
1048 )
1049 },
1050 );
1051 #[cfg(target_arch = "x86_64")]
1052 vcpu.configure(
1053 boot_setup,
1054 self.cpuid.clone(),
1055 self.config.kvm_hyperv,
1056 topology,
1057 self.config.nested,
1058 #[cfg(feature = "igvm")]
1059 self.igvm_enabled,
1060 )?;
1061
1062 #[cfg(target_arch = "aarch64")]
1063 vcpu.configure(self.vm.as_ref(), boot_setup)?;
1064
1065 #[cfg(target_arch = "riscv64")]
1066 vcpu.configure(boot_setup)?;

Callers 2

resizeMethod · 0.80
bootMethod · 0.80

Calls 5

boot_vcpusMethod · 0.80
configureMethod · 0.80
hypervisor_typeMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected