/// Performs sanity checks against the state file and returns specific errors.
Performs sanity checks against the state file and returns specific errors.
Performs sanity checks against the state file and returns specific errors .
pub fn snapshot_state_sanity_check(
    microvm_state: &MicrovmState,
) -> std::result::Result<(), LoadSnapshotError> {
    // Check if the snapshot contains at least 1 vCPU state entry.
    if microvm_state.vcpu_states.is_empty()
        || microvm_state.vcpu_states.len() > MAX_SUPPORTED_VCPUS.into()
    {
        return Err(LoadSnapshotError::InvalidSnapshot(
            "Invalid vCPU count.".to_owned(),
        ));
    }
    // Check if the snapshot contains at least 1 mem region.
    // Upper bound check will be done when creating guest memory by comparing against
    // KVM max supported value kvm_context.max_memslots().
    if microvm_state.memory_state.regions.is_empty() {
        return Err(LoadSnapshotError::InvalidSnapshot(
            "No memory region defined.".to_owned(),
        ));
    }
    #[cfg(target_arch = "x86_64")]
    validate_cpu_vendor(&microvm_state)?;
    #[cfg(target_arch = "aarch64")]
    validate_cpu_manufacturer_id(&microvm_state)?;
    Ok(())
}
pub fn snapshot_state_sanity_check ( microvm_state : & MicrovmState , ) -> std :: result :: Result < ( ) , LoadSnapshotError > { // Check if the snapshot contains at least 1 vCPU state entry. if microvm_state . vcpu_states . is_empty ( ) || microvm_state . vcpu_states . len ( ) > MAX_SUPPORTED_VCPUS . into ( ) { return Err ( LoadSnapshotError :: InvalidSnapshot ( " " . to_owned ( ) , ) ) ; } // Check if the snapshot contains at least 1 mem region. // Upper bound check will be done when creating guest memory by comparing against // KVM max supported value kvm_context.max_memslots(). if microvm_state . memory_state . regions . is_empty ( ) { return Err ( LoadSnapshotError :: InvalidSnapshot ( " " . to_owned ( ) , ) ) ; } # [ cfg ( target_arch " " ) ] validate_cpu_vendor ( & microvm_state ) ? ; # [ cfg ( target_arch " " ) ] validate_cpu_manufacturer_id ( & microvm_state ) ? ; Ok ( ( ) ) }
Performs sanity checks against the state file and returns specific errors.
Performs sanity checks against the state file and returns specific errors .
microvm_state
&MicrovmState