Skip to content

Commit 058a574

Browse files
committed
tests: Add integration test for virtio-mem device reset
Add a test that verifies virtio-mem device reset works end-to-end by unbinding and rebinding the guest driver and checking the device remains functional. Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
1 parent 3d6f04b commit 058a574

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/integration_tests/performance/test_hotplug_memory.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,29 @@ def test_memory_hotplug_latency(
499499
timed_memory_hotplug(uvm, 0, metrics, "hotunplug", "unplug_agg")
500500
timed_memory_hotplug(uvm, hotplug_size, metrics, "hotplug_2nd", "plug_agg")
501501
uvm.kill()
502+
503+
504+
def test_device_reset(uvm_plain):
505+
"""
506+
Test that virtio-mem device reset works.
507+
508+
Note: the Linux virtio-mem driver does not support rebinding when memory is
509+
plugged (the resource region can't be re-registered), so we reset without
510+
any plugged memory and verify the device is functional afterwards.
511+
"""
512+
config = {"total_size_mib": 1024, "slot_size_mib": 128, "block_size_mib": 2}
513+
uvm = uvm_booted_memhp(uvm_plain, None, None, False, config, None, None, None)
514+
515+
# Reset the device via driver unbind/bind.
516+
virtio_dev = uvm.ssh.check_output(
517+
"ls -d /sys/bus/virtio/drivers/virtio_mem/virtio* | xargs -n1 basename"
518+
).stdout.strip()
519+
520+
uvm.ssh.check_output(
521+
f"echo {virtio_dev} > /sys/bus/virtio/drivers/virtio_mem/unbind"
522+
)
523+
uvm.ssh.check_output(f"echo {virtio_dev} > /sys/bus/virtio/drivers/virtio_mem/bind")
524+
525+
# Verify the device is functional after reset by hotplugging memory.
526+
# check_hotplug() asserts that guest mem_total reflects the new size.
527+
check_hotplug(uvm, 256)

0 commit comments

Comments
 (0)