pub fn save_system_registers(vcpu: &VcpuFd, state: &mut Vec<kvm_one_reg>) -> Result<()> {
    // Call KVM_GET_REG_LIST to get all registers available to the guest. For ArmV8 there are
    // less than 500 registers.
    let mut reg_list = RegList::new(500).map_err(Error::FamError)?;
    vcpu.get_reg_list(&mut reg_list)
        .map_err(Error::GetRegList)?;

    // At this point reg_list should contain: core registers and system registers.
    // The register list contains the number of registers and their ids. We will be needing to
    // call KVM_GET_ONE_REG on each id in order to save all of them. We carve out from the list
    // the core registers which are represented in the kernel by kvm_regs structure and for which
    // we can calculate the id based on the offset in the structure.
    reg_list.retain(|regid| is_system_register(*regid));

    // Now, for the rest of the registers left in the previously fetched register list, we are
    // simply calling KVM_GET_ONE_REG.
    let indices = reg_list.as_slice();
    for index in indices.iter() {
        state.push(kvm_bindings::kvm_one_reg {
            id: *index,
            addr: vcpu.get_one_reg(*index).map_err(Error::GetSysRegister)?,
        });
    }

    Ok(())
}
/// Get the state of the system registers.
///
/// # Arguments
///
/// * `vcpu` - Structure for the VCPU that holds the VCPU's fd.
/// * `state` - Structure for returning the state of the system registers.
Get the state of the system registers.
Get the state of the system registers .
pub fn save_system_registers(vcpu: &VcpuFd, state: &mut Vec<kvm_one_reg>) -> Result<()> {
    // Call KVM_GET_REG_LIST to get all registers available to the guest. For ArmV8 there are
    // less than 500 registers.
    let mut reg_list = RegList::new(500).map_err(Error::FamError)?;
    vcpu.get_reg_list(&mut reg_list)
        .map_err(Error::GetRegList)?;
    // At this point reg_list should contain: core registers and system registers.
    // The register list contains the number of registers and their ids. We will be needing to
    // call KVM_GET_ONE_REG on each id in order to save all of them. We carve out from the list
    // the core registers which are represented in the kernel by kvm_regs structure and for which
    // we can calculate the id based on the offset in the structure.
    reg_list.retain(|regid| is_system_register(*regid));
    // Now, for the rest of the registers left in the previously fetched register list, we are
    // simply calling KVM_GET_ONE_REG.
    let indices = reg_list.as_slice();
    for index in indices.iter() {
        state.push(kvm_bindings::kvm_one_reg {
            id: *index,
            addr: vcpu.get_one_reg(*index).map_err(Error::GetSysRegister)?,
        });
    }
    Ok(())
}
pub fn save_system_registers ( vcpu : & VcpuFd , state : & mut Vec < kvm_one_reg > ) -> Result < ( ) > { // Call KVM_GET_REG_LIST to get all registers available to the guest. For ArmV8 there are // less than 500 registers. let mut reg_list = RegList :: new ( 500 ) . map_err ( Error :: FamError ) ? ; vcpu . get_reg_list ( & mut reg_list ) . map_err ( Error :: GetRegList ) ? ; // At this point reg_list should contain: core registers and system registers. // The register list contains the number of registers and their ids. We will be needing to // call KVM_GET_ONE_REG on each id in order to save all of them. We carve out from the list // the core registers which are represented in the kernel by kvm_regs structure and for which // we can calculate the id based on the offset in the structure. reg_list . retain ( | regid | is_system_register ( * regid ) ) ; // Now, for the rest of the registers left in the previously fetched register list, we are // simply calling KVM_GET_ONE_REG. let indices = reg_list . as_slice ( ) ; for index in indices . iter ( ) { state . push ( kvm_bindings :: kvm_one_reg { id : * index , addr : vcpu . get_one_reg ( * index ) . map_err ( Error :: GetSysRegister ) ? , } ) ; } Ok ( ( ) ) }
Get the state of the system registers.
Get the state of the system registers .
vcpu
&VcpuFd
state
&mut Vec<kvm_one_reg>
vcpu
&VcpuFd
state
&mut Vec<kvm_one_reg>