Skip to content

Commit 2c56098

Browse files
committed
tests: Add integration test for virtio-vsock device reset
Add a test that verifies virtio-vsock 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 1504e78 commit 2c56098

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

tests/integration_tests/functional/test_vsock.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,44 @@ def test_vsock_override_fails_without_device(uvm_plain_any, microvm_factory):
367367
)
368368

369369
vm2.mark_killed()
370+
371+
372+
def test_device_reset(uvm_plain_any):
373+
"""
374+
Test that virtio-vsock device reset works.
375+
"""
376+
vm = uvm_plain_any
377+
vm.spawn()
378+
vm.basic_config()
379+
vm.add_net_iface()
380+
vm.api.vsock.put(guest_cid=3, vsock_id="vsock0", uds_path="/" + VSOCK_UDS_PATH)
381+
vm.start()
382+
383+
# Establish a vsock connection before reset so there is active state in the
384+
# backend that must be cleaned up.
385+
uds_path = start_guest_echo_server(vm)
386+
blob_path, blob_hash = make_blob(vm.path)
387+
check_host_connections(uds_path, blob_path, blob_hash)
388+
389+
# Find the virtio vsock device.
390+
virtio_dev = vm.ssh.check_output(
391+
"ls -d /sys/bus/virtio/drivers/vmw_vsock_virtio_transport/virtio*"
392+
" | xargs -n1 basename"
393+
).stdout.strip()
394+
395+
vm.ssh.check_output(
396+
f"echo {virtio_dev} > /sys/bus/virtio/drivers/vmw_vsock_virtio_transport/unbind"
397+
)
398+
399+
# Verify the vsock device is gone.
400+
ret = vm.ssh.run("ls /sys/bus/virtio/drivers/vmw_vsock_virtio_transport/virtio*")
401+
assert ret.returncode != 0
402+
403+
# Rebind and verify the data path works by starting a guest echo server
404+
# and sending data from the host through the vsock.
405+
vm.ssh.check_output(
406+
f"echo {virtio_dev} > /sys/bus/virtio/drivers/vmw_vsock_virtio_transport/bind"
407+
)
408+
uds_path = start_guest_echo_server(vm)
409+
blob_path, blob_hash = make_blob(vm.path)
410+
check_host_connections(uds_path, blob_path, blob_hash)

0 commit comments

Comments
 (0)