Skip to content

Fix qcow2 support for absolute backing_file paths#65

Merged
Schamper merged 4 commits intofox-it:mainfrom
andreia-oca:main
Feb 24, 2026
Merged

Fix qcow2 support for absolute backing_file paths#65
Schamper merged 4 commits intofox-it:mainfrom
andreia-oca:main

Conversation

@andreia-oca
Copy link
Contributor

_open_backing_file assumed that the backing_file path was always a filename relative to the snapshot path. Using .with_name() to concat the whole path broke the use case for absolute path for the backing_file causing ValueError("Invalid name ...").

This change updates the logic to detect whether auto_backing_file is an absolute path. If so, it is used directly; otherwise we fall back to constructing the path relative to the snapshot location.

This will support the following use-cases:
backing file: /home/user/workdir/ubuntu-22.04.qcow2 backing file: ubuntu-22.04.qcow2
backing file: ./ubuntu-22.04-packer.qcow2
backing file: ../../ubuntu-22.04-packer.qcow2

Fixes: #64

andreia-oca and others added 2 commits October 1, 2025 16:46
_open_backing_file assumed that the backing_file path
was always a filename relative to the snapshot path.
Using .with_name() to concat the whole path broke the use
case for absolute path for the backing_file causing
ValueError("Invalid name ...").

This change updates the logic to detect whether auto_backing_file is an
absolute path. If so, it is used directly; otherwise we fall back to
constructing the path relative to the snapshot location.

This will support the following use-cases:
backing file: /home/user/workdir/ubuntu-22.04.qcow2
backing file: ubuntu-22.04.qcow2
backing file: ./ubuntu-22.04-packer.qcow2
backing file: ../../ubuntu-22.04-packer.qcow2

Fixes: fox-it#64

Signed-off-by: Andreia Ocanoaia <andreia.ocanoaia@gmail.com>
Schamper
Schamper previously approved these changes Oct 1, 2025
Copy link
Member

@Schamper Schamper left a comment

Choose a reason for hiding this comment

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

Thanks @andreia-oca, I made a small change that should achieve the same. I also added some unit tests.

The reason I didn't use Path is because in dissect.target we use a custom subclass of it. Using joinpath ensures we stay within that subclass.

Could you maybe verify that it still works as expected on your end?

@codecov
Copy link

codecov bot commented Oct 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.81%. Comparing base (ae08df8) to head (53057a9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
+ Coverage   80.65%   80.81%   +0.16%     
==========================================
  Files          26       26              
  Lines        2367     2367              
==========================================
+ Hits         1909     1913       +4     
+ Misses        458      454       -4     
Flag Coverage Δ
unittests 80.81% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Schamper Schamper merged commit 8007d52 into fox-it:main Feb 24, 2026
19 checks passed
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.

Error loading qcow2 backing-file - ValueError: Invalid name [path]

2 participants