Skip to content

Add documentation for loading QCOW2 snapshots#98

Open
andreia-oca wants to merge 2 commits intofox-it:mainfrom
andreia-oca:andreiaoca/add-qcow2-backing-file-docs
Open

Add documentation for loading QCOW2 snapshots#98
andreia-oca wants to merge 2 commits intofox-it:mainfrom
andreia-oca:andreiaoca/add-qcow2-backing-file-docs

Conversation

@andreia-oca
Copy link

Add a section on how to use the QCOW2 module to load
images that are based on backing files.

This is related to changes on: fox-it/dissect.hypervisor#64

@Horofic Horofic self-requested a review October 2, 2025 14:46
Comment on lines +89 to +101
def analyze_image(snapshot_path: Path, backing_path: Path):
# Open the QCOW2 snapshot along with its backing file and get file/stream handles
snapshot_stream, snapshot_fh, backing_fh, base_stream = open_qcow2_with_backing_file(snapshot_path, backing_path)

# Create a new Dissect target to analyze the disk image
target = Target()
# Add the snapshot stream to the target’s disks
target.disks.add(snapshot_stream)
# Resolve all disks, volumes and filesystems and load an operating system on the current
target.apply()

# Collect data from the snapshot
print(target.users())
Copy link
Member

Choose a reason for hiding this comment

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

With regards to the previous suggestion. I deliberately removed this from here. I think this would be nicer suited in the /usage/use-cases.rst page.

Comment on lines +73 to +87
def open_qcow2_with_backing_file(snapshot_path: Path, backing_path: Path):
# Open base QCOW2 image
backing_fh = backing_path.open("rb")
base_qcow2 = qcow2.QCow2(backing_fh)
base_stream = base_qcow2.open()

# Open snapshot QCOW2 image with base as backing file
snapshot_fh = snapshot_path.open("rb")
snapshot_qcow2 = qcow2.QCow2(
snapshot_fh,
backing_file=base_stream
)
snapshot_stream = snapshot_qcow2.open()

return snapshot_stream, snapshot_fh, backing_fh, base_stream
Copy link
Member

@Horofic Horofic Oct 3, 2025

Choose a reason for hiding this comment

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

I made this more concise in the suggestion comment. Would you mind checking if it still works?

Copy link
Author

@andreia-oca andreia-oca Mar 17, 2026

Choose a reason for hiding this comment

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

Looks good - thanks for the suggestion. Sorry for the looong delay, life happened in between.

The documentation is still up-to-date and the example is working. I am using this backing-file feature since I wrote this and is all good :D

From my part, it would be awesome to merge this PR. Let me know if I can help with anything else.

Copy link
Member

@Horofic Horofic left a comment

Choose a reason for hiding this comment

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

Oops, I meant to click "Request changes"

andreia-oca and others added 2 commits March 17, 2026 14:15
Add a section on how to use QCOW2 module to load
images that are based on backing files.

This is related to changes on: fox-it/dissect.hypervisor#64

Signed-off-by: Andreia Ocanoaia <andreia.ocanoaia@gmail.com>
Co-authored-by: Stefan de Reuver <9864602+Horofic@users.noreply.github.com>
@andreia-oca andreia-oca force-pushed the andreiaoca/add-qcow2-backing-file-docs branch from 587f21a to 474264a Compare March 17, 2026 12:15
@andreia-oca andreia-oca requested a review from Horofic March 17, 2026 12:18
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.

Add documentation for loading QCOW2 snapshots

2 participants