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

Method create_vcpus

vmm/src/cpu.rs:1072–1101  ·  view source on GitHub ↗

Only create new vCPUs if there aren't any inactive ones to reuse

(
        &mut self,
        desired_vcpus: u32,
        snapshot: Option<&Snapshot>,
    )

Source from the content-addressed store, hash-verified

1070
1071 /// Only create new vCPUs if there aren't any inactive ones to reuse
1072 fn create_vcpus(
1073 &mut self,
1074 desired_vcpus: u32,
1075 snapshot: Option<&Snapshot>,
1076 ) -> Result<Vec<Arc<Mutex<Vcpu>>>> {
1077 let mut vcpus: Vec<Arc<Mutex<Vcpu>>> = vec![];
1078 info!(
1079 "Request to create new vCPUs: desired = {}, max = {}, allocated = {}, present = {}",
1080 desired_vcpus,
1081 self.config.max_vcpus,
1082 self.vcpus.len(),
1083 self.present_vcpus()
1084 );
1085
1086 if desired_vcpus > self.config.max_vcpus {
1087 return Err(Error::DesiredVCpuCountExceedsMax);
1088 }
1089
1090 // Only create vCPUs in excess of all the allocated vCPUs.
1091 for cpu_id in self.vcpus.len() as u32..desired_vcpus {
1092 vcpus.push(self.create_vcpu(
1093 cpu_id,
1094 // TODO: The special format of the CPU id can be removed once
1095 // ready to break live upgrade.
1096 snapshot_from_id(snapshot, cpu_id.to_string().as_str()),
1097 )?);
1098 }
1099
1100 Ok(vcpus)
1101 }
1102
1103 #[cfg(target_arch = "aarch64")]
1104 pub fn init_pmu(&self, irq: u32) -> Result<bool> {

Callers 2

create_boot_vcpusMethod · 0.80
resizeMethod · 0.80

Calls 4

snapshot_from_idFunction · 0.85
lenMethod · 0.45
pushMethod · 0.45
create_vcpuMethod · 0.45

Tested by

no test coverage detected