Skip to content

Commit eb9e679

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. Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
1 parent 6836276 commit eb9e679

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
"""Tests for virtio-mem device reset."""
4+
5+
6+
def test_virtio_mem_device_reset(uvm_plain_any):
7+
"""
8+
Test that virtio-mem device reset works.
9+
"""
10+
vm = uvm_plain_any
11+
vm.spawn()
12+
vm.basic_config()
13+
vm.add_net_iface()
14+
vm.api.memory_hotplug.put(total_size_mib=256)
15+
vm.start()
16+
17+
virtio_dev = vm.ssh.check_output(
18+
"ls -d /sys/bus/virtio/drivers/virtio_mem/virtio* | xargs -n1 basename"
19+
).stdout.strip()
20+
21+
vm.ssh.check_output(
22+
f"echo {virtio_dev} > /sys/bus/virtio/drivers/virtio_mem/unbind"
23+
)
24+
25+
# Verify the device is gone.
26+
ret = vm.ssh.run("ls /sys/bus/virtio/drivers/virtio_mem/virtio*")
27+
assert ret.returncode != 0
28+
29+
# Rebind and verify it's back.
30+
vm.ssh.check_output(f"echo {virtio_dev} > /sys/bus/virtio/drivers/virtio_mem/bind")
31+
vm.ssh.check_output("ls /sys/bus/virtio/drivers/virtio_mem/virtio*")

0 commit comments

Comments
 (0)