Skip to content

Commit e9838e1

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 a0c57f4 commit e9838e1

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

0 commit comments

Comments
 (0)