Skip to content

Commit 2ee8dc1

Browse files
committed
fix: specify correct msr_reader binary
The msr_reader.sh was rewritten in C and not is a binary. Update snapshot test to use it. Since the binary is always copied to the VM, remove the hardcoded path from SNAPSHOT_RESTORE_SHARED_NAMES and use msr_reader_bin directly. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 47a987a commit 2ee8dc1

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

tests/integration_tests/functional/test_cpu_features_x86_64.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ def test_cpu_rdmsr(
332332
SNAPSHOT_RESTORE_SHARED_NAMES = {
333333
"snapshot_artifacts_root_dir_wrmsr": "snapshot_artifacts/wrmsr",
334334
"snapshot_artifacts_root_dir_cpuid": "snapshot_artifacts/cpuid",
335-
"msr_reader_host_fname": DATA_FILES / "msr_reader.sh",
336-
"msr_reader_guest_fname": "/tmp/msr_reader.sh",
337335
"msrs_before_fname": "msrs_before.txt",
338336
"msrs_after_fname": "msrs_after.txt",
339337
"cpuid_before_fname": "cpuid_before.txt",
@@ -342,16 +340,12 @@ def test_cpu_rdmsr(
342340
# fmt: on
343341

344342

345-
def dump_msr_state_to_file(dump_fname, ssh_conn, shared_names):
343+
def dump_msr_state_to_file(msr_reader_bin, dump_fname, ssh_conn):
346344
"""
347345
Read MSR state via SSH and dump it into a file.
348346
"""
349-
ssh_conn.scp_put(
350-
shared_names["msr_reader_host_fname"], shared_names["msr_reader_guest_fname"]
351-
)
352-
_, stdout, stderr = ssh_conn.run(
353-
shared_names["msr_reader_guest_fname"], timeout=None
354-
)
347+
ssh_conn.scp_put(msr_reader_bin, "/tmp/msr_reader")
348+
_, stdout, stderr = ssh_conn.run("/tmp/msr_reader")
355349
assert stderr == ""
356350

357351
with open(dump_fname, "w", encoding="UTF-8") as file:
@@ -364,7 +358,9 @@ def dump_msr_state_to_file(dump_fname, ssh_conn, shared_names):
364358
)
365359
@pytest.mark.timeout(900)
366360
@pytest.mark.nonci
367-
def test_cpu_wrmsr_snapshot(microvm_factory, guest_kernel, rootfs, cpu_template_any):
361+
def test_cpu_wrmsr_snapshot(
362+
msr_reader_bin, microvm_factory, guest_kernel, rootfs, cpu_template_any
363+
):
368364
"""
369365
This is the first part of the test verifying
370366
that MSRs retain their values after restoring from a snapshot.
@@ -424,7 +420,7 @@ def test_cpu_wrmsr_snapshot(microvm_factory, guest_kernel, rootfs, cpu_template_
424420

425421
msrs_before_fname = snapshot_artifacts_dir / shared_names["msrs_before_fname"]
426422

427-
dump_msr_state_to_file(msrs_before_fname, vm.ssh, shared_names)
423+
dump_msr_state_to_file(msr_reader_bin, msrs_before_fname, vm.ssh)
428424
# On T2A, the restore test fails with error "cannot allocate memory" so,
429425
# adding delay below as a workaround to unblock the tests for now.
430426
# TODO: Debug the issue and remove this delay. Create below issue to track this:
@@ -470,7 +466,9 @@ def check_msrs_are_equal(before_recs, after_recs):
470466
)
471467
@pytest.mark.timeout(900)
472468
@pytest.mark.nonci
473-
def test_cpu_wrmsr_restore(microvm_factory, cpu_template_any, guest_kernel):
469+
def test_cpu_wrmsr_restore(
470+
msr_reader_bin, microvm_factory, cpu_template_any, guest_kernel
471+
):
474472
"""
475473
This is the second part of the test verifying
476474
that MSRs retain their values after restoring from a snapshot.
@@ -503,7 +501,7 @@ def test_cpu_wrmsr_restore(microvm_factory, cpu_template_any, guest_kernel):
503501

504502
# Dump MSR state to a file for further comparison
505503
msrs_after_fname = snapshot_artifacts_dir / shared_names["msrs_after_fname"]
506-
dump_msr_state_to_file(msrs_after_fname, vm.ssh, shared_names)
504+
dump_msr_state_to_file(msr_reader_bin, msrs_after_fname, vm.ssh)
507505
msrs_before_fname = snapshot_artifacts_dir / shared_names["msrs_before_fname"]
508506

509507
# Compare the two lists of MSR values and assert they are equal

0 commit comments

Comments
 (0)