|
| 1 | +import logging |
| 2 | + |
| 3 | +from avocado.utils import linux_modules |
| 4 | +from virttest import error_context |
| 5 | + |
| 6 | +from provider.win_driver_utils import ( |
| 7 | + get_driver_inf_path, |
| 8 | + install_driver_by_virtio_media, |
| 9 | +) |
| 10 | + |
| 11 | +LOG_JOB = logging.getLogger("avocado.test") |
| 12 | + |
| 13 | + |
| 14 | +@error_context.context_aware |
| 15 | +def run(test, params, env): |
| 16 | + """ |
| 17 | + Vsock basic function test |
| 18 | +
|
| 19 | + 1. Enable vhost_vsock in host |
| 20 | + 2. Boot guest with vhost-vsock-pci device |
| 21 | + 3. Install vsock driver in guest |
| 22 | + 4. Check vsock driver status in guest |
| 23 | + 5. Check vsock provider in guest |
| 24 | +
|
| 25 | + :param test: QEMU test object |
| 26 | + :param params: Dictionary with the test parameters |
| 27 | + :param env: Dictionary with test environment |
| 28 | + """ |
| 29 | + |
| 30 | + LOG_JOB.info("Enable vhost_vsock module in host") |
| 31 | + linux_modules.load_module("vhost_vsock") |
| 32 | + vm = env.get_vm(params["main_vm"]) |
| 33 | + vm.verify_alive() |
| 34 | + session = vm.wait_for_login() |
| 35 | + virtio_win_media_type = params["virtio_win_media_type"] |
| 36 | + driver_name = params["driver_name"] |
| 37 | + test_tool = params["test_tool"] |
| 38 | + |
| 39 | + LOG_JOB.info("Install vsock driver in guest") |
| 40 | + install_driver_by_virtio_media( |
| 41 | + session, |
| 42 | + test, |
| 43 | + devcon_path=params["devcon_path"], |
| 44 | + media_type=virtio_win_media_type, |
| 45 | + driver_name=driver_name, |
| 46 | + device_hwid=params["viosock_hwid"], |
| 47 | + ) |
| 48 | + |
| 49 | + LOG_JOB.info("Check vsock driver status in guest") |
| 50 | + if session.cmd_status(params["vio_driver_chk_cmd"]): |
| 51 | + test.fail("Vsock driver status is not ready.") |
| 52 | + |
| 53 | + LOG_JOB.info("Check vsock provider in guest") |
| 54 | + path = get_driver_inf_path(session, test, virtio_win_media_type, driver_name) |
| 55 | + test_tool_path = path[: path.rfind("\\")] + "\\" + test_tool |
| 56 | + output = session.cmd_output("%s /e" % test_tool_path) |
| 57 | + if params["vsock_provider"] not in output: |
| 58 | + test.fail("Not find vsock provider in guest.") |
| 59 | + |
| 60 | + session.close() |
0 commit comments