vitual_network/../driver_packed: enable on s390x#6792
vitual_network/../driver_packed: enable on s390x#6792smitterl wants to merge 1 commit intoautotest:masterfrom
Conversation
|
WalkthroughAdded a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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.
libvirt/tests/src/virtual_network/elements_and_attributes/driver_packed.py
Show resolved
Hide resolved
libvirt/tests/src/virtual_network/elements_and_attributes/driver_packed.py
Show resolved
Hide resolved
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>
45e07aa to
3550b4f
Compare
There was a problem hiding this comment.
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 forfindcommand output.If the
findcommand returns empty output (no matching features file), or multiple lines (multiple matches), this value is passed directly to_check_features_filewherecatwould 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)
| 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}" |
There was a problem hiding this comment.
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.
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