dissect.hypervisor.disk.qcow2

Module Contents

Classes

QCow2

QCOW2 virtual disk implementation.

QCow2Snapshot

Wrapper class for snapshot table entries.

QCow2Stream

Aligned stream for reading QCow2 files.

L2Table

Convenience class for accessing the L2 table.

Functions

Attributes

dissect.hypervisor.disk.qcow2.HAS_ZSTD = True
class dissect.hypervisor.disk.qcow2.QCow2(fh: BinaryIO | pathlib.Path, data_file: BinaryIO | None = None, backing_file: BinaryIO | None = None, *, allow_no_data_file: bool = False, allow_no_backing_file: bool = False)

QCOW2 virtual disk implementation.

If a data-file is required and fh is not a Path, it’s required to manually pass a file like object in the data_file argument. Otherwise, the data file will be automatically opened if it exists in the same directory. It’s possible to defer opening the data file by passing allow_no_data_file=True.

The same applies to the backing-file. This too can be deferred by passing allow_no_backing_file=True.

Parameters:
  • fh – File handle or path to the QCOW2 file.

  • data_file – Optional file handle for the data file. If not provided and fh is a Path, it will try to open it automatically.

  • backing_file – Optional file handle for the backing file. If not provided and fh is a Path, it will try to open it automatically.

  • allow_no_data_file – If True, allows the QCOW2 file to be opened without a data file.

  • allow_no_backing_file – If True, allows the QCOW2 file to be opened without a backing file.

header
size
cluster_bits
cluster_size
subclusters_per_cluster
subcluster_size
subcluster_bits
l2_bits
l2_size
csize_shift
csize_mask
cluster_offset_mask
backing_format = None
feature_table = None
crypto_header = None
bitmap_header = None
image_data_file = None
unknown_extensions = []
backing_file = None
auto_backing_file = None
image_backing_file = None
l2_table
property snapshots: list[QCow2Snapshot]
property l1_table: list[int]
property has_backing_file: bool
property needs_backing_file: bool
property has_data_file: bool
property needs_data_file: bool
property has_subclusters: bool
open() QCow2Stream

Open the QCow2 file for reading.

class dissect.hypervisor.disk.qcow2.QCow2Snapshot(qcow2: QCow2, offset: int)

Wrapper class for snapshot table entries.

qcow2
offset
header
extra
unknown_extra
id
name
entry_size
open() QCow2Stream

Open the snapshot for reading.

property l1_table: list[int]
class dissect.hypervisor.disk.qcow2.QCow2Stream(qcow2: QCow2, l1_table: list[int] | None = None)

Bases: dissect.util.stream.AlignedStream

Aligned stream for reading QCow2 files.

qcow2
l1_table
class dissect.hypervisor.disk.qcow2.L2Table(qcow2: QCow2, offset: int)

Convenience class for accessing the L2 table.

qcow2
offset
entry(idx: int) int
bitmap(idx: int) int
dissect.hypervisor.disk.qcow2.offset_into_cluster(qcow2: QCow2, offset: int) int
dissect.hypervisor.disk.qcow2.offset_into_subcluster(qcow2: QCow2, offset: int) int
dissect.hypervisor.disk.qcow2.size_to_clusters(qcow2: QCow2, size: int) int
dissect.hypervisor.disk.qcow2.size_to_subclusters(qcow2: QCow2, size: int) int
dissect.hypervisor.disk.qcow2.offset_to_l1_index(qcow2: QCow2, offset: int) int
dissect.hypervisor.disk.qcow2.offset_to_l2_index(qcow2: QCow2, offset: int) int
dissect.hypervisor.disk.qcow2.offset_to_sc_index(qcow2: QCow2, offset: int) int
dissect.hypervisor.disk.qcow2.get_cluster_type(qcow2: QCow2, l2_entry: int) dissect.hypervisor.disk.c_qcow2.QCow2ClusterType
dissect.hypervisor.disk.qcow2.get_subcluster_type(qcow2: QCow2, l2_entry: int, l2_bitmap: int, sc_index: int) dissect.hypervisor.disk.c_qcow2.QCow2SubclusterType
dissect.hypervisor.disk.qcow2.get_subcluster_range_type(qcow2: QCow2, l2_entry: int, l2_bitmap: int, sc_from: int) tuple[dissect.hypervisor.disk.c_qcow2.QCow2SubclusterType, int]
dissect.hypervisor.disk.qcow2.count_contiguous_subclusters(qcow2: QCow2, nb_clusters: int, sc_index: int, l2_table: L2Table, l2_index: int) int