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,
)
| 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 | /// |
nothing calls this directly
no test coverage detected