Skip to content

vitual_network/../driver_packed: enable on s390x#6792

Open
smitterl wants to merge 1 commit intoautotest:masterfrom
smitterl:virtqeue_s390x
Open

vitual_network/../driver_packed: enable on s390x#6792
smitterl wants to merge 1 commit intoautotest:masterfrom
smitterl:virtqeue_s390x

Conversation

@smitterl
Copy link
Contributor

@smitterl smitterl commented Feb 5, 2026

s390x uses virtio-ccw for all virtio downstream. Enable getting the feature attribute for those devices but don't change logic for existing tests which assume virtio-pci.

Summary by CodeRabbit

  • Tests
    • Added support for validating packed virtqueue functionality across PCI and s390 (CCW) bus architectures.
    • Added a new test configuration for the s390-virtio bus type to broaden coverage.
    • Enhanced validation logic with bus-type-specific checks, improved error handling for unknown bus types, and a sensible default bus selection for existing tests.

@smitterl smitterl requested a review from nanli1 February 5, 2026 12:45
@smitterl
Copy link
Contributor Author

smitterl commented Feb 5, 2026

JOB ID     : a1a24312b006f1d87a00838bc701298a359480a0
JOB LOG    : /var/log/avocado/job-results/job-2026-02-05T07.41-a1a2431/job.log
 (1/1) type_specific.io-github-autotest-libvirt.virtual_network.elements_and_attributes.driver_packed: STARTED
 (1/1) type_specific.io-github-autotest-libvirt.virtual_network.elements_and_attributes.driver_packed:  PASS (29.69 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/log/avocado/job-results/job-2026-02-05T07.41-a1a2431/results.html
JOB TIME   : 31.02 s

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Walkthrough

Added a new s390-virtio configuration block with bustype = ccw to driver_packed.cfg. In driver_packed.py the packed-virtqueue check gained a bustype parameter and dispatches to PCI or CCW verification paths. Implemented PCI-specific and CCW-specific checks, a helper to find subchannels by CU Type, a helper to read/validate virtio features files, import of SubchannelPaths, and expanded error handling for unknown bus types; default bustype remains pci.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title contains a typo ('vitual' instead of 'virtual') and uses a vague path reference ('../driver_packed') that obscures the actual change being made. Correct the typo and clarify the title to something like 'Add s390x CCW support for packed virtqueue validation' to better reflect the main change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

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: 2

🤖 Fix all issues with AI agents
In `@libvirt/tests/src/virtual_network/elements_and_attributes/driver_packed.py`:
- Around line 58-70: The helper _check_features_file references an undefined
pci_addr causing a NameError; update _check_features_file to accept a pci_addr
parameter (e.g., def _check_features_file(virtio_features_file, session,
expected_packed_bit, test, pci_addr)) and update all callers (such as
_check_packed_virtqueue_ccw) to pass the VM PCI address through when calling
_check_features_file so the failure message can include the correct pci_addr and
avoid the NameError. Ensure the function signature and all invocations use the
new parameter name consistently.
- Around line 103-110: The current mapping from subchannel to virtio index in
the block using iface_cu_type, _get_subchannel_by_cu_type(...), and index =
subchannel.replace("0", "").replace(".", "") corrupts IDs; change it to extract
the device number component from the subchannel (e.g., take the last
dot-separated component of subchannel) and use that as index before building
virtio_features_file, or alternatively implement a lookup that scans
/sys/bus/virtio/devices/ for the device that links back to the subchannel to
obtain the actual virtio index; update the code around where index is computed
and keep the call to _check_features_file(virtio_features_file, session,
expected_packed_bit, test) unchanged.

s390x uses virtio-ccw for all virtio downstream. Enable getting the
feature attribute for those devices but don't change logic for existing
tests which assume virtio-pci.

Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
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: 1

🤖 Fix all issues with AI agents
In `@libvirt/tests/src/virtual_network/elements_and_attributes/driver_packed.py`:
- Around line 59-70: The helper _check_features_file currently builds and runs a
shell command using virtio_features_file without validating it, so an empty/None
value will produce a confusing shell error; add a guard at the start of
_check_features_file that checks if virtio_features_file is truthy and a
non-empty string, and if not call test.error/test.fail (or test.log.error) with
a clear message that does NOT reference the undefined pci_addr, then
return/raise to avoid running the cat command; keep the rest of the function
(session, expected_packed_bit, test) unchanged.
🧹 Nitpick comments (1)
libvirt/tests/src/virtual_network/elements_and_attributes/driver_packed.py (1)

53-56: Missing validation for find command output.

If the find command returns empty output (no matching features file), or multiple lines (multiple matches), this value is passed directly to _check_features_file where cat would fail with a confusing error message.

Consider validating the output:

♻️ Proposed validation
     find_cmd = 'find / -name features | grep "%s"' % pci_addr
     virtio_features_file = session.cmd_output(find_cmd)
+    virtio_features_file = virtio_features_file.strip()
+    if not virtio_features_file:
+        test.fail(f"Virtio features file not found for PCI address {pci_addr}")
 
     _check_features_file(virtio_features_file, session, expected_packed_bit, test)

Comment on lines +59 to 70
def _check_features_file(virtio_features_file, session, expected_packed_bit, test):
"""
Check packed information from features file

:param virtio_features_file: the features attribute of the virtio device
:param session: VM session
:param expected_packed_bit: Expected packed bit value
:param test: test instance
"""
test.log.debug(f"Using virtio features file: {virtio_features_file}")

packed_bit_cmd = f"cat {virtio_features_file}"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Input validation was removed instead of fixed.

The past review flagged an undefined pci_addr in the error message. The fix removed the entire validation check rather than simplifying the message. Now if virtio_features_file is empty or None, line 70's cat command will fail with a confusing error.

🛡️ Proposed fix to add validation
 def _check_features_file(virtio_features_file, session, expected_packed_bit,  test):
     """
     Check packed information from features file
 
     :param virtio_features_file: the features attribute of the virtio device
     :param session: VM session
     :param expected_packed_bit: Expected packed bit value
     :param test: test instance
     """
+    if not virtio_features_file or not virtio_features_file.strip():
+        test.fail("Virtio features file not found")
     test.log.debug(f"Using virtio features file: {virtio_features_file}")
 
     packed_bit_cmd = f"cat {virtio_features_file}"
🤖 Prompt for AI Agents
In `@libvirt/tests/src/virtual_network/elements_and_attributes/driver_packed.py`
around lines 59 - 70, The helper _check_features_file currently builds and runs
a shell command using virtio_features_file without validating it, so an
empty/None value will produce a confusing shell error; add a guard at the start
of _check_features_file that checks if virtio_features_file is truthy and a
non-empty string, and if not call test.error/test.fail (or test.log.error) with
a clear message that does NOT reference the undefined pci_addr, then
return/raise to avoid running the cat command; keep the rest of the function
(session, expected_packed_bit, test) unchanged.

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