Skip to content

Conversation

@sneh-3
Copy link

@sneh-3 sneh-3 commented Nov 24, 2025

added retry attempt with systemctl restart qemu-guest-agent .

The following test cases were failing before ,

  1. type_specific.io-github-autotest-libvirt.libvirt_mem.positive_test.memory.hot.unplug.max_slots.without_reboot
  2. type_specific.io-github-autotest-libvirt.libvirt_mem.positive_test.memory.hot.unplug.max_slots.with_rand_reboot

Summary by CodeRabbit

  • Tests
    • Enhanced memory detach operation testing with improved error detection and recovery procedures.
    • Added diagnostic capabilities for identifying and handling known unplug errors, including automatic service recovery and logging.

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

…red ,

added retry attempt  with systemctl restart qemu-guest-agent .

The following test cases were failing before ,
1.  type_specific.io-github-autotest-libvirt.libvirt_mem.positive_test.memory.hot.unplug.max_slots.without_reboot
2.  type_specific.io-github-autotest-libvirt.libvirt_mem.positive_test.memory.hot.unplug.max_slots.with_rand_reboot

Signed-off-by: Sneh Shikha Yadav <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

Walkthrough

This change introduces an enhanced retry mechanism in the memory detach process for handling known host unplug errors. When such errors are detected by scanning stderr output (including quoted entries), the code marks the failure, performs an additional detach attempt, and on continued failure, restarts the qemu-guest-agent service and retries. If detach still fails, diagnostic dmesg logs are collected and the VM connection is verified. The implementation adds conditional branches and exception handling around the new retry path.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20-25 minutes

  • Stderr scanning logic: Review the string parsing and quoted entry handling for known error detection
  • Retry mechanism conditions: Verify the logic flow across multiple retry attempts and state transitions
  • Exception handling: Ensure proper exception catching and recovery paths are correctly implemented
  • qemu-guest-agent restart: Confirm the service restart logic is appropriately placed and handles edge cases
  • Diagnostic flow: Review the dmesg collection and VM verification logic for completeness

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 directly addresses the main change: enhanced retry mechanism for detach-device errors during memory hot-unplug with qemu-guest-agent restart.
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

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a302a6f and f91afe3.

📒 Files selected for processing (1)
  • libvirt/tests/src/libvirt_mem.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
libvirt/tests/src/libvirt_mem.py (1)
libvirt/tests/src/controller/controller_functional.py (1)
  • detach_device (563-576)
🪛 ast-grep (0.40.0)
libvirt/tests/src/libvirt_mem.py

[warning] 750-750: The function mktemp is deprecated. When using this function, it is possible for an attacker to modify the created file before the filename is returned. Use NamedTemporaryFile() instead and pass it the delete=False parameter.
Context: tempfile.mktemp(dir=data_dir.get_tmp_dir())
Note: [CWE-377]: Insecure Temporary File [OWASP A01:2021]: Broken Access Control [REFERENCES]
https://docs.python.org/3/library/tempfile.html#tempfile.mktemp
https://owasp.org/Top10/A01_2021-Broken_Access_Control

(avoid-mktemp-python)

🪛 Ruff (0.14.5)
libvirt/tests/src/libvirt_mem.py

735-735: Loop control variable retry_attempt not used within loop body

Rename unused retry_attempt to _retry_attempt

(B007)


742-742: Do not catch blind exception: Exception

(BLE001)


742-742: Local variable detail is assigned to but never used

Remove assignment to unused variable detail

(F841)


745-745: Undefined name subprocess

(F821)


750-750: Do not catch blind exception: Exception

(BLE001)


750-750: Local variable detail2 is assigned to but never used

Remove assignment to unused variable detail2

(F841)


751-751: Use of insecure and deprecated function (mktemp)

(S306)


757-757: Do not catch blind exception: Exception

(BLE001)

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.

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.

1 participant