guest_os_booting: fix customize_loader custom path on AArch64#6871
guest_os_booting: fix customize_loader custom path on AArch64#6871BulaYoungR wants to merge 1 commit into
Conversation
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>
WalkthroughThis PR modifies Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 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
📒 Files selected for processing (1)
libvirt/tests/src/guest_os_booting/ovmf_firmware/ovmf_loader.py
| 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)), | ||
| ): |
There was a problem hiding this comment.
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.
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
/tmp) when the specified destination is inaccessible or missing.