Skip to content

Conversation

@qiankehan
Copy link
Contributor

@qiankehan qiankehan commented Nov 29, 2025

It covers the test for https://issues.redhat.com/browse/RHEL-80533

Summary by CodeRabbit

  • Tests
    • Improved virtual machine log file tracking for both root and non-root user contexts.
    • Enhanced test validation with additional checks for warnings in QEMU log files to improve reliability.

✏️ Tip: You can customize this high-level summary in your review settings.

It covers the test for https://issues.redhat.com/browse/RHEL-80533

Signed-off-by: Han Han <hhan@redhat.com>
@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Walkthrough

This pull request adds QEMU log file monitoring capability to passt network function tests. Configuration changes add explicit qemu_log_file paths for both root and non-root user variants. The test code introduces a new optional qemu_log_file parameter and extends the existing warning check logic to additionally inspect the QEMU log file for warning entries when vhostuser and warning_check are enabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Configuration file: Straightforward addition of two similar log path entries; homogeneous, low-complexity changes
  • Test logic: New conditional grep check nested within existing vhostuser/warning_check block; linear flow with no branching complexity
  • Potential attention areas:
    • Verify the log file paths are correct for both root and non-root user contexts
    • Confirm the grep pattern in the QEMU log check correctly identifies warning entries without false positives
    • Ensure the new optional parameter maintains backward compatibility

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 summarizes the main change: adding a QEMU warning check for vhostuser in the passt_function test, which aligns with both modified files.
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

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

user_id = 107
log_dir = /run/user/${user_id}
socket_dir = f'/run/libvirt/qemu/passt/'
qemu_log_file = /var/log/libvirt/qemu/avocado-vt-vm1.log
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @nanli1 , is there any way to replace the hard-coding guest name with a variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

@qiankehan hi hhan, we could use main_vm parameter
qemu_log_file = /var/log/libvirt/qemu/${main_vm}.log
we could also use libvirt.check_logfile("fail|error", qemu_log_file, str_in_log=False) to check

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

🧹 Nitpick comments (2)
libvirt/tests/cfg/virtual_network/passt/passt_function.cfg (1)

17-24: Avoid hard‑coding the QEMU log filename; derive it from the VM name instead

Both qemu_log_file entries hard‑code avocado-vt-vm1.log. If main_vm / unpr_vm_name is ever changed or differs between root and unprivileged runs, the Python side will grep the wrong log file and silently miss QEMU warnings.

Consider instead passing either:

  • a directory (e.g. /var/log/libvirt/qemu and /home/${test_user}/.cache/libvirt/qemu) and let the test build <vm_name>.log, or
  • a single template parameter (e.g. qemu_log_dir or qemu_log_file_pattern) used by the Python code to compute the exact path from the actual vm_name.

This reduces duplication and keeps log paths aligned with VM naming.

libvirt/tests/src/virtual_network/passt/passt_function.py (1)

76-76: Validate qemu_log_file when vhostuser and warning_check are enabled

qemu_log_file is taken directly from params with no validation. If another cfg reuses this test with vhostuser=yes and warning_check=yes but forgets to set qemu_log_file, the later grep will run against "None" / a non‑existent file and the test will silently skip QEMU warning coverage.

To make misconfiguration obvious, consider guarding this early, for example:

warning_check = params.get('warning_check')
qemu_log_file = params.get('qemu_log_file')

if vhostuser and warning_check and not qemu_log_file:
    test.cancel('qemu_log_file must be set when vhostuser and warning_check are enabled')

This keeps current behavior for correctly configured jobs while failing fast on incomplete configs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 644eeb6 and a114b51.

📒 Files selected for processing (2)
  • libvirt/tests/cfg/virtual_network/passt/passt_function.cfg (1 hunks)
  • libvirt/tests/src/virtual_network/passt/passt_function.py (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: qiankehan
Repo: autotest/tp-libvirt PR: 6652
File: libvirt/tests/cfg/virtual_network/passt/passt_function.cfg:106-106
Timestamp: 2025-11-24T10:44:47.801Z
Learning: In libvirt/tests/cfg/virtual_network/passt/passt_function.cfg, passt test cases have only one interface, so running `dhcpcd` without specifying an interface is safe and doesn't cause network disruption.
📚 Learning: 2025-11-24T10:44:47.801Z
Learnt from: qiankehan
Repo: autotest/tp-libvirt PR: 6652
File: libvirt/tests/cfg/virtual_network/passt/passt_function.cfg:106-106
Timestamp: 2025-11-24T10:44:47.801Z
Learning: In libvirt/tests/cfg/virtual_network/passt/passt_function.cfg, passt test cases have only one interface, so running `dhcpcd` without specifying an interface is safe and doesn't cause network disruption.

Applied to files:

  • libvirt/tests/cfg/virtual_network/passt/passt_function.cfg
  • libvirt/tests/src/virtual_network/passt/passt_function.py
🧬 Code graph analysis (1)
libvirt/tests/src/virtual_network/passt/passt_function.py (2)
libvirt/tests/src/virtual_network/passt/passt_reconnect.py (1)
  • run (28-148)
libvirt/tests/src/virtual_network/passt/passt_transfer_file.py (1)
  • run (116-197)
🪛 Ruff (0.14.6)
libvirt/tests/src/virtual_network/passt/passt_function.py

143-143: Function call with shell=True parameter identified, security issue

(S604)


150-150: Function call with shell=True parameter identified, security issue

(S604)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Python 3.12
  • GitHub Check: Python 3.11
  • GitHub Check: Python 3.9
  • GitHub Check: Python 3.8

Comment on lines +140 to +155
if vhostuser:
if warning_check:
# Exclude the warning like: 'warning : qemuDomainObjTaintMsg:5529 : Domain ... is tainted: custom-monitor'
check_warning = process.run('grep -v "qemuDomainObjTaintMsg.*custom-monitor {0}"|grep "warning :"'.format(libvirtd_debug_file),
shell=True,
ignore_status=True,
logger=LOG)
if check_warning.exit_status == 0:
test.fail('Get warnings in virtqemud log: {0}'.format(check_warning.stdout_text))

check_qemu_warning = process.run('grep warning: {0}'.format(qemu_log_file),
shell=True,
ignore_status=True,
logger=LOG)
if not check_qemu_warning.exit_status:
test.fail('Get warnings in qemu log {0}: {1}'.format(qemu_log_file, check_qemu_warning.stdout_text))
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Clear QEMU log before test run to avoid false positives and assert log presence

The new QEMU log warning check is useful, but there are a couple of reliability issues:

  1. Stale warnings across runs (flaky failures)
    grep warning: {qemu_log_file} runs on whatever is currently in the log file. Unlike libvirtd_debug_file, this QEMU log is never removed or truncated before starting the VM in this test. If previous runs left warnings in the same log, this test will fail even when the current run is clean.

    Suggest explicitly clearing the QEMU log before vm.start() when vhostuser and warning_check are enabled, e.g.:

    if vhostuser and warning_check and qemu_log_file:
        if os.path.exists(qemu_log_file):
            os.remove(qemu_log_file)

    This mirrors the “fresh log per run” behavior you already enforce for libvirtd_debug_file and avoids history‑dependent failures.

  2. No assertion that the QEMU log actually exists
    If qemu_log_file points to the wrong place or QEMU logging is disabled, grep will return a non‑zero status and the current if not check_qemu_warning.exit_status: condition will quietly treat that as “no warnings”. That means the test can give a false sense of safety while never reading any QEMU log at all.

    After the VM run and before grepping, consider asserting that the log file exists when warning_check is on, for example:

    if vhostuser and warning_check:
        if not os.path.exists(qemu_log_file):
            test.fail(f'QEMU log file "{qemu_log_file}" not found for warning check')

These changes would make the new warning coverage both more robust and less flaky, without altering the intended pass/fail semantics when the log is correctly produced.

🧰 Tools
🪛 Ruff (0.14.6)

143-143: Function call with shell=True parameter identified, security issue

(S604)


150-150: Function call with shell=True parameter identified, security issue

(S604)

🤖 Prompt for AI Agents
In libvirt/tests/src/virtual_network/passt/passt_function.py around lines
140-155, the QEMU log grep can use stale data and may silently pass when the
QEMU log doesn't exist; before starting the VM when vhostuser and warning_check
are enabled, ensure the qemu_log_file is cleared (remove or truncate if it
exists) so each run has a fresh log, and after the VM run but before grepping
assert that qemu_log_file exists (fail the test if it does not) so the grep
actually checks current QEMU output rather than old data or a missing file.

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