-
Notifications
You must be signed in to change notification settings - Fork 182
netkvm: add test for RX queue size parameter validation #4386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
heywji
wants to merge
1
commit into
autotest:master
Choose a base branch
from
heywji:add_netkvm_rxcapacity2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| - netkvm_rxcapacity: | ||
| type = netkvm_rxcapacity | ||
| only Windows | ||
| cdroms += " virtio winutils" | ||
| image_snapshot = yes | ||
| driver_verifier = netkvm | ||
| wmi_cmd_url = "WIN_UTILS:\\netkvm\\WMI\\netkvm-wmi.cmd" | ||
| netkvm_wmi_path = "C:\\netkvm-wmi.cmd" | ||
| wmi_cmd_copy_cmd = "xcopy ${wmi_cmd_url} ${wmi_cmd_path} /Y" | ||
| ping_target = "223.5.5.5" | ||
| variants: | ||
| - rx_queue_256_rxbuf_1024: | ||
| nic_extra_params_nic1 += ",rx_queue_size=256" | ||
| expected_rx_queue_size = 256 | ||
| rx_capacity_value = "1024" | ||
| - rx_queue_1024_rxbuf_1024: | ||
| nic_extra_params_nic1 += ",rx_queue_size=1024" | ||
| expected_rx_queue_size = 1024 | ||
| rx_capacity_value = "1024" | ||
| - rx_queue_512_rxbuf_2048: | ||
| nic_extra_params_nic1 += ",rx_queue_size=512" | ||
| expected_rx_queue_size = 512 | ||
| rx_capacity_value = "2048" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,117 @@ | ||||||
| import re | ||||||
|
|
||||||
| from virttest import error_context, utils_misc, utils_net, utils_test | ||||||
| from virttest.utils_windows import virtio_win | ||||||
|
|
||||||
|
|
||||||
| @error_context.context_aware | ||||||
| def run(test, params, env): | ||||||
| """ | ||||||
| Test netkvm RX capacity with different RX queue sizes. | ||||||
|
|
||||||
| This test verifies that the RX queue size setting in QEMU matches | ||||||
| the reported RxQueueSize in Windows guest when MaxRxBuffers is set. | ||||||
|
|
||||||
| Test steps: | ||||||
| 1) Boot VM with specific rx_queue_size parameter | ||||||
| 2) Set Init.MaxRxBuffers parameter using netkvmco.exe | ||||||
| 3) Verify the parameter was set correctly | ||||||
| 4) Check RxQueueSize using netkvm-wmi.cmd | ||||||
| 5) Verify RxQueueSize matches expected value | ||||||
|
|
||||||
| :param test: QEMU test object | ||||||
| :param params: Dictionary with the test parameters | ||||||
| :param env: Dictionary with test environment | ||||||
| """ | ||||||
|
|
||||||
| def set_and_verify_rxcapacity(session, vm, test, value): | ||||||
| """ | ||||||
| Set RxCapacity parameter and verify it was set correctly. | ||||||
|
|
||||||
| :param session: VM session info | ||||||
| :param vm: QEMU test object | ||||||
| :param test: QEMU test object | ||||||
| :param value: Value to set for RxCapacity | ||||||
| """ | ||||||
| error_context.context(f"Setting RxCapacity to {value}", test.log.info) | ||||||
| utils_net.set_netkvm_param_value(vm, "RxCapacity", value) | ||||||
|
|
||||||
| current_value = utils_net.get_netkvm_param_value(vm, "RxCapacity") | ||||||
| if current_value != value: | ||||||
| test.fail( | ||||||
| f"Failed to set RxCapacity. Expected: {value}, Got: {current_value}" | ||||||
| ) | ||||||
| test.log.info("Successfully set RxCapacity to %s", value) | ||||||
|
|
||||||
| def get_rxqueue_size_from_wmi(session, test, netkvm_wmi_path, wmi_cmd_copy_cmd): | ||||||
| """ | ||||||
| Get RxQueueSize from netkvm-wmi.cmd output. | ||||||
|
|
||||||
| :return: RxQueueSize value as integer | ||||||
| """ | ||||||
| wmi_cmd_copy_cmd = utils_misc.set_winutils_letter(session, wmi_cmd_copy_cmd) | ||||||
| session.cmd(wmi_cmd_copy_cmd, timeout=30) | ||||||
|
|
||||||
| error_context.context("Getting RxQueueSize from WMI", test.log.info) | ||||||
| wmi_output = session.cmd_output(f"{netkvm_wmi_path} cfg", timeout=30) | ||||||
| test.log.info("WMI output:\n%s", wmi_output) | ||||||
|
|
||||||
| rx_queue_pattern = r"RxQueueSize=(\d+)" | ||||||
| match = re.search(rx_queue_pattern, wmi_output) | ||||||
| if not match: | ||||||
| test.fail("Could not find RxQueueSize in WMI output") | ||||||
|
|
||||||
| rx_queue_size = int(match.group(1)) | ||||||
| test.log.info("Found RxQueueSize: %s", rx_queue_size) | ||||||
| return rx_queue_size | ||||||
|
|
||||||
| timeout = params.get_numeric("login_timeout", 360) | ||||||
| expected_rx_queue_size = params.get_numeric("expected_rx_queue_size") | ||||||
| rx_capacity_value = params.get("rx_capacity_value", "1024") | ||||||
| netkvm_wmi_path = params.get("netkvm_wmi_path", "C:\\netkvm-wmi.cmd") | ||||||
| wmi_cmd_copy_cmd = params.get("wmi_cmd_copy_cmd") | ||||||
|
|
||||||
| vm_name = params["main_vm"] | ||||||
| vm = env.get_vm(vm_name) | ||||||
| vm.verify_alive() | ||||||
| session = vm.wait_for_serial_login(timeout=timeout) | ||||||
|
|
||||||
| virtio_win.prepare_netkvmco(vm) | ||||||
| try: | ||||||
| set_and_verify_rxcapacity(session, vm, test, rx_capacity_value) | ||||||
| actual_rx_queue_size = get_rxqueue_size_from_wmi( | ||||||
| session, test, netkvm_wmi_path, wmi_cmd_copy_cmd | ||||||
| ) | ||||||
| error_context.context( | ||||||
| f"Verifying RxQueueSize. Expected: {expected_rx_queue_size}, " | ||||||
| f"Actual: {actual_rx_queue_size}", | ||||||
| test.log.info, | ||||||
| ) | ||||||
|
|
||||||
| if actual_rx_queue_size != expected_rx_queue_size: | ||||||
| test.fail( | ||||||
| f"RxQueueSize mismatch. Expected: {expected_rx_queue_size}, " | ||||||
| f"Got: {actual_rx_queue_size}" | ||||||
| ) | ||||||
|
|
||||||
| test.log.info( | ||||||
| "SUCCESS: RxQueueSize %s matches expected value %s", | ||||||
| actual_rx_queue_size, | ||||||
| expected_rx_queue_size, | ||||||
| ) | ||||||
|
|
||||||
| error_context.context("Testing network connectivity", test.log.info) | ||||||
| status, output = utils_net.ping( | ||||||
| "223.5.5.5", count=10, timeout=60, session=session | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ) | ||||||
| if status: | ||||||
| test.fail(f"Ping test failed: {output}") | ||||||
|
|
||||||
| package_lost = utils_test.get_loss_ratio(output) | ||||||
| if package_lost != 0: | ||||||
| test.fail(f"Ping test shows {package_lost}% packet loss") | ||||||
|
|
||||||
| test.log.info("Network connectivity test passed") | ||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| finally: | ||||||
| session.close() | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can copy netkvm-wmi.cmd after prepare_netkvmco