Skip to content

Commit ea3b738

Browse files
committed
fix: Remove duplicate check for MAX_SUPPORT_VCPUS from restore path
This check already happens in `update_vm_config`, so no need to do it a second time in `snapshot_state_sanity_check`. Signed-off-by: Patrick Roy <[email protected]>
1 parent f6c87ff commit ea3b738

File tree

2 files changed

+1
-30
lines changed

2 files changed

+1
-30
lines changed

src/vmm/src/persist.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::resources::VmResources;
3232
use crate::snapshot::Snapshot;
3333
use crate::vmm_config::boot_source::BootSourceConfig;
3434
use crate::vmm_config::instance_info::InstanceInfo;
35-
use crate::vmm_config::machine_config::{MachineConfigUpdate, VmConfigError, MAX_SUPPORTED_VCPUS};
35+
use crate::vmm_config::machine_config::{MachineConfigUpdate, VmConfigError};
3636
use crate::vmm_config::snapshot::{
3737
CreateSnapshotParams, LoadSnapshotParams, MemBackendType, SnapshotType,
3838
};
@@ -329,8 +329,6 @@ pub fn validate_cpu_manufacturer_id(microvm_state: &MicrovmState) {
329329
/// Error type for [`snapshot_state_sanity_check`].
330330
#[derive(Debug, thiserror::Error, displaydoc::Display, PartialEq, Eq)]
331331
pub enum SnapShotStateSanityCheckError {
332-
/// Invalid vCPU count.
333-
InvalidVcpuCount,
334332
/// No memory region defined.
335333
NoMemory,
336334
}
@@ -339,13 +337,6 @@ pub enum SnapShotStateSanityCheckError {
339337
pub fn snapshot_state_sanity_check(
340338
microvm_state: &MicrovmState,
341339
) -> Result<(), SnapShotStateSanityCheckError> {
342-
// Check if the snapshot contains at least 1 vCPU state entry.
343-
if microvm_state.vcpu_states.is_empty()
344-
|| microvm_state.vcpu_states.len() > MAX_SUPPORTED_VCPUS.into()
345-
{
346-
return Err(SnapShotStateSanityCheckError::InvalidVcpuCount);
347-
}
348-
349340
// Check if the snapshot contains at least 1 mem region.
350341
// Upper bound check will be done when creating guest memory by comparing against
351342
// KVM max supported value kvm_context.max_memslots().

src/vmm/tests/integration_tests.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -305,26 +305,6 @@ fn test_snapshot_load_sanity_checks() {
305305
.vcpu_states
306306
.append(&mut microvm_state.vcpu_states.clone());
307307
}
308-
309-
// After this line we will have 33 vCPUs, FC max si 32.
310-
microvm_state
311-
.vcpu_states
312-
.push(microvm_state.vcpu_states[0].clone());
313-
314-
// Validate sanity checks fail because there are too many vCPUs.
315-
assert_eq!(
316-
snapshot_state_sanity_check(&microvm_state),
317-
Err(SnapShotStateSanityCheckError::InvalidVcpuCount)
318-
);
319-
320-
// Remove all vCPUs states from microvm state.
321-
microvm_state.vcpu_states.clear();
322-
323-
// Validate sanity checks fail because there is no vCPU in state.
324-
assert_eq!(
325-
snapshot_state_sanity_check(&microvm_state),
326-
Err(SnapShotStateSanityCheckError::InvalidVcpuCount)
327-
);
328308
}
329309

330310
fn get_microvm_state_from_snapshot() -> MicrovmState {

0 commit comments

Comments
 (0)