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

Method new

vmm/src/cpu.rs:515–535  ·  view source on GitHub ↗

Constructs a new VCPU for `vm`. # Arguments `id` - Represents the CPU number between [0, max vcpus). `vm` - The virtual machine this vcpu will get attached to. `vm_ops` - Optional object for exit handling. `cpu_vendor` - CPU vendor as reported by __cpuid(0x0)

(
        id: u32,
        apic_id: u32,
        vm: &dyn hypervisor::Vm,
        vm_ops: Option<Arc<dyn VmOps>>,
        #[cfg(target_arch = "x86_64")] cpu_vendor: CpuVendor,
    )

Source from the content-addressed store, hash-verified

513 /// * `vm_ops` - Optional object for exit handling.
514 /// * `cpu_vendor` - CPU vendor as reported by __cpuid(0x0)
515 pub fn new(
516 id: u32,
517 apic_id: u32,
518 vm: &dyn hypervisor::Vm,
519 vm_ops: Option<Arc<dyn VmOps>>,
520 #[cfg(target_arch = "x86_64")] cpu_vendor: CpuVendor,
521 ) -> Result<Self> {
522 let vcpu = vm
523 .create_vcpu(apic_id, vm_ops)
524 .map_err(|e| Error::VcpuCreate(e.into()))?;
525 // Initially the cpuid per vCPU is the one supported by this VM.
526 Ok(Vcpu {
527 vcpu,
528 id,
529 #[cfg(target_arch = "aarch64")]
530 mpidr: 0,
531 saved_state: None,
532 #[cfg(target_arch = "x86_64")]
533 vendor: cpu_vendor,
534 })
535 }
536
537 /// Configures a vcpu and should be called once per vcpu when created.
538 ///

Callers

nothing calls this directly

Calls 10

newFunction · 0.85
get_cpu_vendorMethod · 0.80
iterMethod · 0.80
create_vcpuMethod · 0.45
get_max_vcpusMethod · 0.45
hypervisor_typeMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected