Skip to content

guest_os_booting: fix customize_loader custom path on AArch64#6871

Open
BulaYoungR wants to merge 1 commit into
autotest:masterfrom
BulaYoungR:fix/ovmf-loader-customize-loader-aarch64-path
Open

guest_os_booting: fix customize_loader custom path on AArch64#6871
BulaYoungR wants to merge 1 commit into
autotest:masterfrom
BulaYoungR:fix/ovmf-loader-customize-loader-aarch64-path

Conversation

@BulaYoungR
Copy link
Copy Markdown

@BulaYoungR BulaYoungR commented May 12, 2026

Params often point custom_loader_path under /usr/share/edk2/ovmf/, which does not exist on AArch64 hosts. Resolve to a writable path under the Avocado data directory or /tmp, rewrite loader_dict paths to match, makedirs before copy2, and surface OSError text on failure.

Fixes positive_test.customize_loader on arm64-mmio.

Committer: Bolatbek Issakh bissakh@redhat.com

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved handling of custom OVMF loader paths: The system now automatically falls back to writable locations (Avocado data directory or /tmp) when the specified destination is inaccessible or missing.
    • Enhanced error messages to provide better diagnostics when custom loader creation fails.
    • Fixed path resolution to ensure parent directories are created before attempting file operations.

Review Change Stack

Params often point custom_loader_path under /usr/share/edk2/ovmf/, which
does not exist on AArch64 hosts. Resolve to a writable path under the
Avocado data directory or /tmp, rewrite loader_dict paths to match,
makedirs before copy2, and surface OSError text on failure.

Fixes positive_test.customize_loader on arm64-mmio.

Committer: Bolatbek Issakh <bissakh@redhat.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Walkthrough

This PR modifies ovmf_loader.py to handle cases where the custom loader destination path is missing or not writable. It introduces two helper functions—_replace_path_in_obj() to recursively rewrite path strings in configuration objects, and _resolve_custom_loader_path() to redirect the loader to either the Avocado data directory or /tmp when needed. The create_custom_loader() function now ensures parent directories exist before copying and includes OS error details in failure messages. The run() function is updated to resolve the custom loader path and update the loader configuration before proceeding with loader creation and cleanup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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: fixing a custom loader path issue on AArch64, which aligns with the PR's primary objective of resolving positive_test.customize_loader failures by redirecting paths to writable locations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_loader.py`:
- Around line 53-55: The fallback filenames built from
os.path.basename(custom_loader_path) in the list of candidate paths can collide
across parallel tests; change the logic in ovmf_loader.py that composes those
fallback paths (references: custom_loader_path, data_dir.get_data_dir(),
tempfile.gettempdir()) to generate a run-unique filename (for example by
appending a short uuid4 or pid+timestamp) and use that unique name consistently
when creating the file and when removing it during cleanup so each test run
cleans only its own temp file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc32ae69-b07f-496f-a499-575f0d66b98d

📥 Commits

Reviewing files that changed from the base of the PR and between c96ab65 and c31983c.

📒 Files selected for processing (1)
  • libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_loader.py

Comment on lines +53 to +55
os.path.join(data_dir.get_data_dir(), "images", os.path.basename(custom_loader_path)),
os.path.join(tempfile.gettempdir(), os.path.basename(custom_loader_path)),
):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use a unique fallback filename per run to avoid cross-test clobbering.

At Line 53 and Line 54, the fallback path uses a shared basename under shared directories. Parallel jobs can overwrite each other’s file and then remove it at Line 140/Line 141 during cleanup.

Proposed fix
-    for alt in (
-        os.path.join(data_dir.get_data_dir(), "images", os.path.basename(custom_loader_path)),
-        os.path.join(tempfile.gettempdir(), os.path.basename(custom_loader_path)),
-    ):
-        parent = os.path.dirname(alt)
+    base = os.path.basename(custom_loader_path)
+    stem, ext = os.path.splitext(base)
+    for parent in (
+        os.path.join(data_dir.get_data_dir(), "images"),
+        tempfile.gettempdir(),
+    ):
         try:
             os.makedirs(parent, exist_ok=True)
         except OSError:
             continue
         if os.access(parent, os.W_OK):
+            fd, alt = tempfile.mkstemp(
+                prefix=f"{stem}_",
+                suffix=ext or ".fd",
+                dir=parent,
+            )
+            os.close(fd)
             test.log.info(
                 "custom_loader_path %r not usable (dir=%r); using %s instead",
                 custom_loader_path,
                 dest_dir,
                 alt,
             )
             loader_dict = _replace_path_in_obj(loader_dict, custom_loader_path, alt)
             return alt, loader_dict
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_loader.py` around lines
53 - 55, The fallback filenames built from os.path.basename(custom_loader_path)
in the list of candidate paths can collide across parallel tests; change the
logic in ovmf_loader.py that composes those fallback paths (references:
custom_loader_path, data_dir.get_data_dir(), tempfile.gettempdir()) to generate
a run-unique filename (for example by appending a short uuid4 or pid+timestamp)
and use that unique name consistently when creating the file and when removing
it during cleanup so each test run cleans only its own temp 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.

1 participant