Skip to content

Commit 8660ee5

Browse files
committed
vsock_driver_check: Add script to test vsock driver
Test vsock driver in Windows VM, will check vsock driver status and provider. ID:4795 Signed-off-by: Leidong Wang <leidwang@redhat.com>
1 parent 1339503 commit 8660ee5

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- vsock_driver_check:
2+
type = vsock_driver_check
3+
only Windows
4+
cdroms += " virtio"
5+
virtio_win_media_type = iso
6+
required_virtio_win_prewhql = [0.1.294, )
7+
required_virtio_win = [1.9.49.0, )
8+
vsock_module = vhost_vsock
9+
vsocks = vhost_vsock0
10+
driver_name = viosock
11+
vsock_name = VirtIO Socket Driver
12+
vsock_provider = Virtio Vsock STREAM
13+
viosock_hwid = '"PCI\VEN_1AF4&DEV_1053" "PCI\VEN_1AF4&DEV_1012"'
14+
i386:
15+
devcon_dirname = "x86"
16+
x86_64:
17+
devcon_dirname = "amd64"
18+
devcon_path = "WIN_UTILS:\devcon\${devcon_dirname}\devcon.exe"
19+
vio_driver_chk_cmd = 'driverquery /si | find /i "${vsock_name}"'
20+
test_tool = "viosocklib-test.exe"

qemu/tests/vsock_driver_check.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

Comments
 (0)