Skip to content

Conversation

zhentang-tz
Copy link
Contributor

@zhentang-tz zhentang-tz commented Sep 5, 2025

add disk image url for fix "Unable to download boot image" cases

guest_os_booting.boot_order.disk_device.seabios.disk_boot_order.multi_disks_bootable

guest_os_booting.boot_order.disk_device.ovmf.disk_boot_order.multi_disks_bootable

Summary by CodeRabbit

  • Bug Fixes

    • Corrects disk image selection for OVMF firmware by automatically using the “-ovmf.qcow2” variant when downloading, reducing boot failures in boot-from-disk scenarios.
  • Tests

    • Improves reliability of guest OS boot tests by handling OVMF-specific images automatically.
    • Maintains existing download and validation flow for non-OVMF cases, ensuring no regressions for other firmware types.

add disk image url for fix "Unable to download boot image" cases

guest_os_booting.boot_order.disk_device.seabios.disk_boot_order.multi_disks_bootable

guest_os_booting.boot_order.disk_device.ovmf.disk_boot_order.multi_disks_bootable

Signed-off-by: zhentang-tz <[email protected]>
@zhentang-tz
Copy link
Contributor Author

zhentang-tz commented Sep 12, 2025

avocado run --vt-type libvirt --vt-machine-type q35 guest_os_booting.boot_order.disk_device.seabios.disk_boot_order.multi_disks_bootable guest_os_booting.boot_order.disk_device.ovmf.disk_boot_order.multi_disks_bootable --job-timeout 1200 --vt-connect-uri qemu:///system

JOB ID : 4c4644a3c701afdd6d312889006b2dfaec1fd867
JOB LOG : /var/log/avocado/job-results/job-2025-09-12T03.21-4c4644a/job.log
(1/2) type_specific.io-github-autotest-libvirt.guest_os_booting.boot_order.disk_device.seabios.disk_boot_order.multi_disks_bootable: STARTED
(1/2) type_specific.io-github-autotest-libvirt.guest_os_booting.boot_order.disk_device.seabios.disk_boot_order.multi_disks_bootable: PASS (333.19 s)
(2/2) type_specific.io-github-autotest-libvirt.guest_os_booting.boot_order.disk_device.ovmf.disk_boot_order.multi_disks_bootable: STARTED
(2/2) type_specific.io-github-autotest-libvirt.guest_os_booting.boot_order.disk_device.ovmf.disk_boot_order.multi_disks_bootable: PASS (343.70 s)
RESULTS : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML : /var/log/avocado/job-results/job-2025-09-12T03.21-4c4644a/results.html
JOB TIME : 679.56 s

@zhentang-tz zhentang-tz marked this pull request as ready for review September 12, 2025 07:42
Copy link

coderabbitai bot commented Sep 12, 2025

Walkthrough

Adds firmware_type handling in parse_disks_attrs to adjust the disk image URL when using OVMF: if disk1_img is set and download is enabled, the URL’s trailing ".qcow2" is replaced with "-ovmf.qcow2" before download. Other download and validation logic remains unchanged.

Changes

Cohort / File(s) Summary
Boot order test: OVMF-specific URL rewrite
libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py
Introduces firmware_type = params.get("firmware_type"). When download_disk1_img is true and disk1_img is set and firmware_type == "ovmf", rewrites disk1_img_url from *.qcow2 to *-ovmf.qcow2 prior to download; rest of flow unchanged.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Tester
    participant Parser as parse_disks_attrs
    participant Downloader as Image Downloader
    participant Validator as Image Validator

    Tester->>Parser: Provide params (includes firmware_type)
    alt download_disk1_img && disk1_img set
        opt firmware_type == "ovmf"
            Note right of Parser: Rewrite URL: *.qcow2 → *-ovmf.qcow2
        end
        Parser->>Downloader: Download disk1_img_url
        Downloader-->>Parser: Download result
        Parser->>Validator: Validate image
        Validator-->>Parser: Validation result
    else
        Note over Parser: No download performed
    end
    Parser-->>Tester: Parsed disk attributes
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (3 passed)

✅ 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 clearly and concisely describes the primary change — fixing an image download URL issue related to guest OS booting — which matches the PR's modifications to disk image URL selection for OVMF; it is specific enough for a teammate to understand the main intent and contains no noise or file lists.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Poem

I twitch my nose at OVMF moon,
Hop to the repo, hum a tune.
Swap .qcow2 for ovmf’s delight,
A hyphen hop—now named just right.
Burrow built, boot path neat—
Carrots compiled, tests complete! 🥕✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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: 1

🧹 Nitpick comments (1)
libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py (1)

32-32: Normalize firmware_type to avoid case/None surprises

Use a default and lowercase once to make the comparison robust.

-    firmware_type = params.get("firmware_type")
+    firmware_type = params.get("firmware_type", "").lower()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f69f72e and 5c6d467.

📒 Files selected for processing (1)
  • libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py (1 hunks)

Comment on lines +36 to 38
if firmware_type == "ovmf":
disk1_img_url = disk1_img_url.removesuffix('.qcow2') + '-ovmf.qcow2'
if not disk1_img_url or not utils_misc.wait_for(
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix OVMF URL rewrite: avoid Python 3.9-only API, empty-URL regression, and double "-ovmf"

  • str.removesuffix requires Python 3.9+.
  • If disk1_img_url is empty, current code produces "-ovmf.qcow2" and bypasses the empty-URL guard.
  • If URL already ends with "-ovmf.qcow2", current code yields "...-ovmf-ovmf.qcow2".
-            if firmware_type == "ovmf":
-                disk1_img_url = disk1_img_url.removesuffix('.qcow2') + '-ovmf.qcow2'
+            if firmware_type == "ovmf" and disk1_img_url:
+                # Avoid double suffix and keep Py<3.9 compatibility
+                if disk1_img_url.endswith("-ovmf.qcow2"):
+                    pass  # already the OVMF variant
+                elif disk1_img_url.endswith(".qcow2"):
+                    disk1_img_url = f"{disk1_img_url[:-6]}-ovmf.qcow2"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if firmware_type == "ovmf":
disk1_img_url = disk1_img_url.removesuffix('.qcow2') + '-ovmf.qcow2'
if not disk1_img_url or not utils_misc.wait_for(
if firmware_type == "ovmf" and disk1_img_url:
# Avoid double suffix and keep Py<3.9 compatibility
if disk1_img_url.endswith("-ovmf.qcow2"):
pass # already the OVMF variant
elif disk1_img_url.endswith(".qcow2"):
disk1_img_url = f"{disk1_img_url[:-6]}-ovmf.qcow2"
if not disk1_img_url or not utils_misc.wait_for(
🤖 Prompt for AI Agents
In libvirt/tests/src/guest_os_booting/boot_order/boot_from_disk_device.py around
lines 36-38, the OVMF URL rewrite uses str.removesuffix (Py3.9+) and runs even
when disk1_img_url is empty or already ends with "-ovmf.qcow2", causing
empty-URL and double-suffix bugs; fix by first checking disk1_img_url truthiness
before any rewrite, then only rewrite when firmware_type == "ovmf" AND
disk1_img_url is non-empty, and perform a safe suffix adjustment using endswith
checks (if it endswith '.qcow2' and not '-ovmf.qcow2', replace the '.qcow2'
suffix with '-ovmf.qcow2'; otherwise leave the URL unchanged) so the code works
on older Python versions and avoids empty or duplicated suffixes.

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