pub fn configure_x86_64(
        &mut self,
        guest_mem: &GuestMemoryMmap,
        kernel_start_addr: GuestAddress,
        vcpu_config: &VcpuConfig,
    ) -> Result<()> {
        let cpuid_vm_spec = VmSpec::new(self.id, vcpu_config.vcpu_count, vcpu_config.ht_enabled)
            .map_err(Error::CpuId)?;

        filter_cpuid(&mut self.cpuid, &cpuid_vm_spec).map_err(|e| {
            error!("Failure in configuring CPUID for vcpu {}: {:?}", self.id, e);
            Error::CpuId(e)
        })?;

        if let Some(template) = vcpu_config.cpu_template {
            match template {
                CpuFeaturesTemplate::T2 => {
                    t2::set_cpuid_entries(&mut self.cpuid, &cpuid_vm_spec).map_err(Error::CpuId)?
                }
                CpuFeaturesTemplate::C3 => {
                    c3::set_cpuid_entries(&mut self.cpuid, &cpuid_vm_spec).map_err(Error::CpuId)?
                }
            }
        }

        self.fd
            .set_cpuid2(&self.cpuid)
            .map_err(Error::VcpuSetCpuid)?;

        arch::x86_64::msr::setup_msrs(&self.fd).map_err(Error::MSRSConfiguration)?;
        arch::x86_64::regs::setup_regs(&self.fd, kernel_start_addr.raw_value() as u64, self.id)
            .map_err(Error::REGSConfiguration)?;
        arch::x86_64::regs::setup_fpu(&self.fd).map_err(Error::FPUConfiguration)?;
        arch::x86_64::regs::setup_sregs(guest_mem, &self.fd, self.id)
            .map_err(Error::SREGSConfiguration)?;
        arch::x86_64::interrupts::set_lint(&self.fd).map_err(Error::LocalIntConfiguration)?;
        Ok(())
    }
/// Configures a x86_64 specific vcpu and should be called once per vcpu.
///
/// # Arguments
///
/// * `machine_config` - The machine configuration of this microvm needed for the CPUID configuration.
/// * `guest_mem` - The guest memory used by this microvm.
/// * `kernel_start_addr` - Offset from `guest_mem` at which the kernel starts.
Configures a x86_64 specific vcpu and should be called once per vcpu.
Configures a x86_64 specific vcpu and should be called once per vcpu .
pub fn configure_x86_64(
        &mut self,
        guest_mem: &GuestMemoryMmap,
        kernel_start_addr: GuestAddress,
        vcpu_config: &VcpuConfig,
    ) -> Result<()> {
        let cpuid_vm_spec = VmSpec::new(self.id, vcpu_config.vcpu_count, vcpu_config.ht_enabled)
            .map_err(Error::CpuId)?;
        filter_cpuid(&mut self.cpuid, &cpuid_vm_spec).map_err(|e| {
            error!("Failure in configuring CPUID for vcpu {}: {:?}", self.id, e);
            Error::CpuId(e)
        })?;
        if let Some(template) = vcpu_config.cpu_template {
            match template {
                CpuFeaturesTemplate::T2 => {
                    t2::set_cpuid_entries(&mut self.cpuid, &cpuid_vm_spec).map_err(Error::CpuId)?
                }
                CpuFeaturesTemplate::C3 => {
                    c3::set_cpuid_entries(&mut self.cpuid, &cpuid_vm_spec).map_err(Error::CpuId)?
                }
            }
        }
        self.fd
            .set_cpuid2(&self.cpuid)
            .map_err(Error::VcpuSetCpuid)?;
        arch::x86_64::msr::setup_msrs(&self.fd).map_err(Error::MSRSConfiguration)?;
        arch::x86_64::regs::setup_regs(&self.fd, kernel_start_addr.raw_value() as u64, self.id)
            .map_err(Error::REGSConfiguration)?;
        arch::x86_64::regs::setup_fpu(&self.fd).map_err(Error::FPUConfiguration)?;
        arch::x86_64::regs::setup_sregs(guest_mem, &self.fd, self.id)
            .map_err(Error::SREGSConfiguration)?;
        arch::x86_64::interrupts::set_lint(&self.fd).map_err(Error::LocalIntConfiguration)?;
        Ok(())
    }
pub fn configure_x86_64 ( & mut self , guest_mem : & GuestMemoryMmap , kernel_start_addr : GuestAddress , vcpu_config : & VcpuConfig , ) -> Result < ( ) > { let cpuid_vm_spec = VmSpec :: new ( self . id , vcpu_config . vcpu_count , vcpu_config . ht_enabled ) . map_err ( Error :: CpuId ) ? ; filter_cpuid ( & mut self . cpuid , & cpuid_vm_spec ) . map_err ( | e | { error ! ( " " self id e ) ; Error :: CpuId ( e ) } ) ? ; if let Some ( template ) = vcpu_config . cpu_template { match template { CpuFeaturesTemplate :: T2 => { t2 :: set_cpuid_entries ( & mut self . cpuid , & cpuid_vm_spec ) . map_err ( Error :: CpuId ) ? } CpuFeaturesTemplate :: C3 => { c3 :: set_cpuid_entries ( & mut self . cpuid , & cpuid_vm_spec ) . map_err ( Error :: CpuId ) ? } } } self . fd . set_cpuid2 ( & self . cpuid ) . map_err ( Error :: VcpuSetCpuid ) ? ; arch :: x86_64 :: msr :: setup_msrs ( & self . fd ) . map_err ( Error :: MSRSConfiguration ) ? ; arch :: x86_64 :: regs :: setup_regs ( & self . fd , kernel_start_addr . raw_value ( ) as u64 , self . id ) . map_err ( Error :: REGSConfiguration ) ? ; arch :: x86_64 :: regs :: setup_fpu ( & self . fd ) . map_err ( Error :: FPUConfiguration ) ? ; arch :: x86_64 :: regs :: setup_sregs ( guest_mem , & self . fd , self . id ) . map_err ( Error :: SREGSConfiguration ) ? ; arch :: x86_64 :: interrupts :: set_lint ( & self . fd ) . map_err ( Error :: LocalIntConfiguration ) ? ; Ok ( ( ) ) }
Configures a x86_64 specific vcpu and should be called once per vcpu.
Configures a x86_64 specific vcpu and should be called once per vcpu .
&mut self
guest_mem
&GuestMemoryMmap
kernel_start_addr
GuestAddress
vcpu_config
&VcpuConfig