Skip to content

Commit 37e1e78

Browse files
committed
test: Cover all CPU templates in snapshot/restore wrmsr/cpuid tests
Previously only a limited set of static CPU templates were supported. Now it covers all the cases (no CPU template, all the static CPU templates and all the custom CPU templates). It will help support newer CPU templates (e.g. a CPU template for Intel Sapphire Rapids). Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent faf91ea commit 37e1e78

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/integration_tests/functional/test_cpu_features_x86_64.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def dump_msr_state_to_file(dump_fname, ssh_conn, shared_names):
363363
)
364364
@pytest.mark.timeout(900)
365365
@pytest.mark.nonci
366-
def test_cpu_wrmsr_snapshot(microvm_factory, guest_kernel, rootfs, msr_cpu_template):
366+
def test_cpu_wrmsr_snapshot(microvm_factory, guest_kernel, rootfs, cpu_template_any):
367367
"""
368368
This is the first part of the test verifying
369369
that MSRs retain their values after restoring from a snapshot.
@@ -389,10 +389,10 @@ def test_cpu_wrmsr_snapshot(microvm_factory, guest_kernel, rootfs, msr_cpu_templ
389389
vm.basic_config(
390390
vcpu_count=vcpus,
391391
mem_size_mib=guest_mem_mib,
392-
cpu_template=msr_cpu_template,
393392
track_dirty_pages=True,
394393
boot_args="msr.allow_writes=on",
395394
)
395+
vm.set_cpu_template(cpu_template_any)
396396
vm.start()
397397

398398
# Make MSR modifications
@@ -413,7 +413,7 @@ def test_cpu_wrmsr_snapshot(microvm_factory, guest_kernel, rootfs, msr_cpu_templ
413413
snapshot_artifacts_dir = (
414414
Path(shared_names["snapshot_artifacts_root_dir_wrmsr"])
415415
/ guest_kernel.name
416-
/ (msr_cpu_template if msr_cpu_template else "none")
416+
/ get_cpu_template_name_str(cpu_template_any)
417417
)
418418
clean_and_mkdir(snapshot_artifacts_dir)
419419

@@ -465,7 +465,7 @@ def check_msrs_are_equal(before_recs, after_recs):
465465
)
466466
@pytest.mark.timeout(900)
467467
@pytest.mark.nonci
468-
def test_cpu_wrmsr_restore(microvm_factory, msr_cpu_template, guest_kernel):
468+
def test_cpu_wrmsr_restore(microvm_factory, cpu_template_any, guest_kernel):
469469
"""
470470
This is the second part of the test verifying
471471
that MSRs retain their values after restoring from a snapshot.
@@ -481,7 +481,7 @@ def test_cpu_wrmsr_restore(microvm_factory, msr_cpu_template, guest_kernel):
481481
"""
482482

483483
shared_names = SNAPSHOT_RESTORE_SHARED_NAMES
484-
cpu_template_dir = msr_cpu_template if msr_cpu_template else "none"
484+
cpu_template_dir = get_cpu_template_name_str(cpu_template_any)
485485
snapshot_artifacts_dir = (
486486
Path(shared_names["snapshot_artifacts_root_dir_wrmsr"])
487487
/ guest_kernel.name
@@ -520,7 +520,7 @@ def dump_cpuid_to_file(dump_fname, ssh_conn):
520520
)
521521
@pytest.mark.timeout(900)
522522
@pytest.mark.nonci
523-
def test_cpu_cpuid_snapshot(microvm_factory, guest_kernel, rootfs, msr_cpu_template):
523+
def test_cpu_cpuid_snapshot(microvm_factory, guest_kernel, rootfs, cpu_template_any):
524524
"""
525525
This is the first part of the test verifying
526526
that CPUID remains the same after restoring from a snapshot.
@@ -543,13 +543,13 @@ def test_cpu_cpuid_snapshot(microvm_factory, guest_kernel, rootfs, msr_cpu_templ
543543
vm.basic_config(
544544
vcpu_count=1,
545545
mem_size_mib=1024,
546-
cpu_template=msr_cpu_template,
547546
track_dirty_pages=True,
548547
)
548+
vm.set_cpu_template(cpu_template_any)
549549
vm.start()
550550

551551
# Dump CPUID to a file that will be published to S3 for the 2nd part of the test
552-
cpu_template_dir = get_cpu_template_name_str(msr_cpu_template)
552+
cpu_template_dir = get_cpu_template_name_str(cpu_template_any)
553553
snapshot_artifacts_dir = (
554554
Path(shared_names["snapshot_artifacts_root_dir_cpuid"])
555555
/ guest_kernel.name
@@ -587,7 +587,7 @@ def check_cpuid_is_equal(before_cpuid_fname, after_cpuid_fname):
587587
)
588588
@pytest.mark.timeout(900)
589589
@pytest.mark.nonci
590-
def test_cpu_cpuid_restore(microvm_factory, guest_kernel, msr_cpu_template):
590+
def test_cpu_cpuid_restore(microvm_factory, guest_kernel, cpu_template_any):
591591
"""
592592
This is the second part of the test verifying
593593
that CPUID remains the same after restoring from a snapshot.
@@ -601,7 +601,7 @@ def test_cpu_cpuid_restore(microvm_factory, guest_kernel, msr_cpu_template):
601601
"""
602602

603603
shared_names = SNAPSHOT_RESTORE_SHARED_NAMES
604-
cpu_template_dir = get_cpu_template_name_str(msr_cpu_template)
604+
cpu_template_dir = get_cpu_template_name_str(cpu_template_any)
605605
snapshot_artifacts_dir = (
606606
Path(shared_names["snapshot_artifacts_root_dir_cpuid"])
607607
/ guest_kernel.name

0 commit comments

Comments
 (0)