Add documentation for loading QCOW2 snapshots#98
Add documentation for loading QCOW2 snapshots#98andreia-oca wants to merge 2 commits intofox-it:mainfrom
Conversation
| 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()) |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
I made this more concise in the suggestion comment. Would you mind checking if it still works?
There was a problem hiding this comment.
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.
Horofic
left a comment
There was a problem hiding this comment.
Oops, I meant to click "Request changes"
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>
587f21a to
474264a
Compare
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