Skip to content

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 <[email protected]>
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 77.84%. Comparing base (0c89766) to head (5c6faa4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
+ Coverage   77.66%   77.84%   +0.18%     
==========================================
  Files          26       26              
  Lines        2207     2207              
==========================================
+ Hits         1714     1718       +4     
+ Misses        493      489       -4     
Flag Coverage Δ
unittests 77.84% <100.00%> (+0.18%) ⬆️

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.

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