Skip to content

Conversation

@heywji
Copy link
Contributor

@heywji heywji commented Oct 21, 2025

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.

ID: 2914

Signed-off-by: wji [email protected]

Summary by CodeRabbit

  • Tests
    • Added Windows-only QEMU tests validating NIC RX capacity and RxQueueSize reporting between host and guest.
    • Includes new test configuration and test module covering multiple RX queue/buffer variants with expected values.
    • Verifies guest-reported queue size via WMI-based check and performs a basic connectivity test to ensure network stability.

@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Walkthrough

Adds a Windows-only QEMU test configuration (qemu/tests/cfg/netkvm_rxcapacity.cfg) and a new test module (qemu/tests/netkvm_rxcapacity.py). The test sets QEMU RxCapacity, verifies the setting, runs a Windows WMI helper (netkvm-wmi.cmd) to read the guest-reported RxQueueSize (parsed with regex), compares that value to the expected variant value, and performs a 10-packet ping to verify connectivity. The test logs and fails on mismatches, missing data, or packet loss and ensures the VM session is closed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Areas to focus on:

  • qemu/tests/netkvm_rxcapacity.py: correctness of invoking the WMI helper, capturing its output, and the regex used to extract RxQueueSize.
  • Validation flow: setting RxCapacity, reading it back, and comparing against expected values per variant.
  • Error handling and resource cleanup (finally/session.close).
  • Ping/connectivity check parsing and packet-loss detection.
  • qemu/tests/cfg/netkvm_rxcapacity.cfg: Windows-only gating and per-variant parameter correctness.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a test for RX queue size parameter validation in netkvm. It is specific, concise, and directly relates to the core functionality being added.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@heywji
Copy link
Contributor Author

heywji commented Oct 21, 2025

Test Result: PASS

 (1/3) Host_RHEL.m10.u1.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_256_rxbuf_1024.q35:  PASS (169.88 s)
 (2/3) Host_RHEL.m10.u1.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_1024_rxbuf_1024.q35: STARTED
 (2/3) Host_RHEL.m10.u1.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_1024_rxbuf_1024.q35:  PASS (170.95 s)
 (3/3) Host_RHEL.m10.u1.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_512_rxbuf_2048.q35: STARTED
 (3/3) Host_RHEL.m10.u1.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_512_rxbuf_2048.q35:  PASS (168.55 s)
RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
qemu/tests/netkvm_rxcapacity.py (1)

27-44: Minor: Docstring parameter description could be more precise.

Line 32 describes vm as "QEMU test object", but it should be "VM object" since it's the virtual machine instance, not the test object (which is passed separately).

Apply this diff if you'd like to improve the docstring:

-        :param vm: QEMU test object
+        :param vm: VM object
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02fbc5f and 69d06e3.

📒 Files selected for processing (2)
  • qemu/tests/cfg/netkvm_rxcapacity.cfg (1 hunks)
  • qemu/tests/netkvm_rxcapacity.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/netkvm_rxcapacity.py (1)
qemu/tests/ovs_host_vlan.py (1)
  • ping (53-76)
🔇 Additional comments (5)
qemu/tests/cfg/netkvm_rxcapacity.cfg (1)

10-22: LGTM: Test variants are well-structured.

The three test variants provide good coverage with different rx_queue_size and rx_capacity_value combinations.

qemu/tests/netkvm_rxcapacity.py (4)

1-5: LGTM: Imports are appropriate.

All necessary modules are imported for the test functionality.


7-25: LGTM: Well-documented test entry point.

The function signature and docstring clearly describe the test purpose and steps.


70-100: LGTM: Test setup and verification logic is sound.

The test properly initializes the VM, sets RxCapacity, retrieves RxQueueSize from WMI, and verifies the values match expectations.


114-115: LGTM: Proper cleanup in finally block.

The session is correctly closed in a finally block to ensure cleanup occurs even if the test fails.

@heywji heywji force-pushed the add_netkvm_rxcapacity2 branch from 69d06e3 to e5a5d74 Compare November 4, 2025 06:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
qemu/tests/netkvm_rxcapacity.py (1)

27-45: Remove unused session parameter in helper.

set_and_verify_rxcapacity never references its session argument. Please drop it (and the corresponding argument at the call site) to avoid confusion about dependencies.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69d06e3 and e5a5d74.

📒 Files selected for processing (2)
  • qemu/tests/cfg/netkvm_rxcapacity.cfg (1 hunks)
  • qemu/tests/netkvm_rxcapacity.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • qemu/tests/cfg/netkvm_rxcapacity.cfg
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/netkvm_rxcapacity.py (1)
qemu/tests/ovs_host_vlan.py (1)
  • ping (53-76)

Comment on lines 52 to 55
netkvm_wmi_path = params.get("wmi_cmd_path", "C:\\netkvm-wmi.cmd")
wmi_cmd_copy_cmd = params.get("wmi_cmd_copy_cmd")
wmi_cmd_copy_cmd = utils_misc.set_winutils_letter(session, wmi_cmd_copy_cmd)
session.cmd(wmi_cmd_copy_cmd, timeout=30)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this part to preparation phase would be better.

vm.verify_alive()
session = vm.wait_for_serial_login(timeout=timeout)

virtio_win.prepare_netkvmco(vm)
Copy link
Contributor

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

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: Wenkang Ji <[email protected]>
@heywji heywji force-pushed the add_netkvm_rxcapacity2 branch from e5a5d74 to f4ad792 Compare November 17, 2025 07:12
@heywji
Copy link
Contributor Author

heywji commented Nov 17, 2025

@leidwang Hi Leidong, could you please review this patch again?

Test Result: PASS

 (1/3) Host_RHEL.m10.u1.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_256_rxbuf_1024.q35:  PASS (145.37 s)
 (2/3) Host_RHEL.m10.u1.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_1024_rxbuf_1024.q35: STARTED
 (2/3) Host_RHEL.m10.u1.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_1024_rxbuf_1024.q35:  PASS (145.87 s)
 (3/3) Host_RHEL.m10.u1.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_512_rxbuf_2048.q35: STARTED
 (3/3) Host_RHEL.m10.u1.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.netkvm_rxcapacity.rx_queue_512_rxbuf_2048.q35:  PASS (145.70 s)
RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
qemu/tests/netkvm_rxcapacity.py (2)

71-71: Verify parameter name matches config file.

This line uses params.get("netkvm_wmi_path", ...), but a previous review comment indicated this should be "wmi_cmd_path" to match the config file definition. The past comment was marked as "✅ Addressed in commit e5a5d74", but the code still shows "netkvm_wmi_path".

Please verify:

  1. Is this a regression where the fix was reverted?
  2. Was the config file updated instead to use "netkvm_wmi_path"?
  3. Does the current configuration properly pass the WMI path?

Run the following script to check which parameter name is defined in the config file:

#!/bin/bash
# Description: Check which parameter name is used in the config file

# Search for wmi parameter definitions in the config file
rg -n "wmi.*path" qemu/tests/cfg/netkvm_rxcapacity.cfg

103-114: Verify ping target is configurable.

Lines 104-105 use a hardcoded external IP address (223.5.5.5) for the connectivity test. A previous review comment identified this as a major issue because it creates an external network dependency and will fail in isolated test environments. The past comment was marked as "✅ Addressed in commit e5a5d74", but the code still shows the hardcoded IP.

Please verify:

  1. Is this a regression where the fix was reverted?
  2. Is the connectivity test intended to always use this specific external IP?
  3. Should this be made configurable as originally suggested?

Run the following script to check if ping_target is defined in the config:

#!/bin/bash
# Description: Check if ping_target parameter is defined in the config file

# Search for ping_target parameter in the config file
rg -n "ping_target" qemu/tests/cfg/netkvm_rxcapacity.cfg
🧹 Nitpick comments (2)
qemu/tests/netkvm_rxcapacity.py (2)

27-44: Remove unused session parameter.

The session parameter is declared in the function signature and documented at line 31, but it's never used in the function body. The function only uses the vm parameter to set and get the netkvm parameter value.

Consider removing the unused parameter to improve code clarity:

-    def set_and_verify_rxcapacity(session, vm, test, value):
+    def set_and_verify_rxcapacity(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

And update the call site at line 81:

-        set_and_verify_rxcapacity(session, vm, test, rx_capacity_value)
+        set_and_verify_rxcapacity(vm, test, rx_capacity_value)

46-66: Consider moving WMI script copy to the preparation phase.

Lines 52-53 copy the WMI script to the guest, which is a setup operation. This is currently embedded inside a helper function that's conceptually about retrieving data. For better separation of concerns and code clarity, consider moving the script copy operation to the main test flow, immediately after prepare_netkvmco at line 79.

Based on learnings (leidwang's comment).

Suggested refactor:

 def get_rxqueue_size_from_wmi(session, test, netkvm_wmi_path):
     """
     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)

And in the main test body:

 virtio_win.prepare_netkvmco(vm)
+
+wmi_cmd_copy_cmd = utils_misc.set_winutils_letter(session, wmi_cmd_copy_cmd)
+session.cmd(wmi_cmd_copy_cmd, timeout=30)
+
 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
+        session, test, netkvm_wmi_path
     )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5a5d74 and f4ad792.

📒 Files selected for processing (2)
  • qemu/tests/cfg/netkvm_rxcapacity.cfg (1 hunks)
  • qemu/tests/netkvm_rxcapacity.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • qemu/tests/cfg/netkvm_rxcapacity.cfg
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/netkvm_rxcapacity.py (1)
qemu/tests/ovs_host_vlan.py (1)
  • ping (53-76)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants