Skip to content

Commit 69d06e3

Browse files
committed
netkvm: add test for RX queue size parameter validation
This patch adds a test to verify that QEMU's rx_queue_size parameter correctly influences the Windows guest's reported RxQueueSize value when RxCapacity is configured via netkvmco.exe. Signed-off-by: wji <[email protected]>
1 parent 02fbc5f commit 69d06e3

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
- netkvm_rxcapacity:
2+
type = netkvm_rxcapacity
3+
only Windows
4+
cdroms += " virtio winutils"
5+
image_snapshot = yes
6+
driver_verifier = netkvm
7+
wmi_cmd_url = "WIN_UTILS:\\netkvm\\WMI\\netkvm-wmi.cmd"
8+
wmi_cmd_path = "C:\\netkvm-wmi.cmd"
9+
wmi_cmd_copy_cmd = "xcopy ${wmi_cmd_url} ${wmi_cmd_path} /Y"
10+
variants:
11+
- rx_queue_256_rxbuf_1024:
12+
nic_extra_params_nic1 += ",rx_queue_size=256"
13+
expected_rx_queue_size = 256
14+
rx_capacity_value = "1024"
15+
- rx_queue_1024_rxbuf_1024:
16+
nic_extra_params_nic1 += ",rx_queue_size=1024"
17+
expected_rx_queue_size = 1024
18+
rx_capacity_value = "1024"
19+
- rx_queue_512_rxbuf_2048:
20+
nic_extra_params_nic1 += ",rx_queue_size=512"
21+
expected_rx_queue_size = 512
22+
rx_capacity_value = "2048"

qemu/tests/netkvm_rxcapacity.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import re
2+
3+
from virttest import error_context, utils_misc, utils_net, utils_test
4+
from virttest.utils_windows import virtio_win
5+
6+
7+
@error_context.context_aware
8+
def run(test, params, env):
9+
"""
10+
Test netkvm RX capacity with different RX queue sizes.
11+
12+
This test verifies that the RX queue size setting in QEMU matches
13+
the reported RxQueueSize in Windows guest when MaxRxBuffers is set.
14+
15+
Test steps:
16+
1) Boot VM with specific rx_queue_size parameter
17+
2) Set Init.MaxRxBuffers parameter using netkvmco.exe
18+
3) Verify the parameter was set correctly
19+
4) Check RxQueueSize using netkvm-wmi.cmd
20+
5) Verify RxQueueSize matches expected value
21+
22+
:param test: QEMU test object
23+
:param params: Dictionary with the test parameters
24+
:param env: Dictionary with test environment
25+
"""
26+
27+
def set_and_verify_rxcapacity(session, vm, test, value):
28+
"""
29+
Set RxCapacity parameter and verify it was set correctly.
30+
31+
:param session: VM session info
32+
:param vm: QEMU test object
33+
:param test: QEMU test object
34+
:param value: Value to set for RxCapacity
35+
"""
36+
error_context.context(f"Setting RxCapacity to {value}", test.log.info)
37+
utils_net.set_netkvm_param_value(vm, "RxCapacity", value)
38+
39+
current_value = utils_net.get_netkvm_param_value(vm, "RxCapacity")
40+
if current_value != value:
41+
test.fail(
42+
f"Failed to set RxCapacity. Expected: {value}, Got: {current_value}"
43+
)
44+
test.log.info("Successfully set RxCapacity to %s", value)
45+
46+
def get_rxqueue_size_from_wmi(session, test, params):
47+
"""
48+
Get RxQueueSize from netkvm-wmi.cmd output.
49+
50+
:return: RxQueueSize value as integer
51+
"""
52+
netkvm_wmi_path = params.get("netkvm_wmi_path", "C:\\netkvm-wmi.cmd")
53+
wmi_cmd_copy_cmd = params.get("wmi_cmd_copy_cmd")
54+
wmi_cmd_copy_cmd = utils_misc.set_winutils_letter(session, wmi_cmd_copy_cmd)
55+
session.cmd(wmi_cmd_copy_cmd, timeout=30)
56+
57+
error_context.context("Getting RxQueueSize from WMI", test.log.info)
58+
wmi_output = session.cmd_output(f"{netkvm_wmi_path} cfg", timeout=30)
59+
test.log.info("WMI output:\n%s", wmi_output)
60+
61+
rx_queue_pattern = r"RxQueueSize=(\d+)"
62+
match = re.search(rx_queue_pattern, wmi_output)
63+
if not match:
64+
test.fail("Could not find RxQueueSize in WMI output")
65+
66+
rx_queue_size = int(match.group(1))
67+
test.log.info("Found RxQueueSize: %s", rx_queue_size)
68+
return rx_queue_size
69+
70+
timeout = params.get_numeric("login_timeout", 360)
71+
expected_rx_queue_size = params.get_numeric("expected_rx_queue_size")
72+
rx_capacity_value = params.get("rx_capacity_value", "1024")
73+
74+
vm_name = params["main_vm"]
75+
vm = env.get_vm(vm_name)
76+
vm.verify_alive()
77+
session = vm.wait_for_serial_login(timeout=timeout)
78+
79+
virtio_win.prepare_netkvmco(vm)
80+
try:
81+
set_and_verify_rxcapacity(session, vm, test, rx_capacity_value)
82+
actual_rx_queue_size = get_rxqueue_size_from_wmi(session, test, params)
83+
error_context.context(
84+
f"Verifying RxQueueSize. Expected: {expected_rx_queue_size}, "
85+
f"Actual: {actual_rx_queue_size}",
86+
test.log.info,
87+
)
88+
89+
if actual_rx_queue_size != expected_rx_queue_size:
90+
test.fail(
91+
f"RxQueueSize mismatch. Expected: {expected_rx_queue_size}, "
92+
f"Got: {actual_rx_queue_size}"
93+
)
94+
95+
test.log.info(
96+
"SUCCESS: RxQueueSize %s matches expected value %s",
97+
actual_rx_queue_size,
98+
expected_rx_queue_size,
99+
)
100+
101+
error_context.context("Testing network connectivity", test.log.info)
102+
status, output = utils_net.ping(
103+
"223.5.5.5", count=10, timeout=60, session=session
104+
)
105+
if status:
106+
test.fail(f"Ping test failed: {output}")
107+
108+
package_lost = utils_test.get_loss_ratio(output)
109+
if package_lost != 0:
110+
test.fail(f"Ping test shows {package_lost}% packet loss")
111+
112+
test.log.info("Network connectivity test passed")
113+
114+
finally:
115+
session.close()

0 commit comments

Comments
 (0)