From bb217b637e1f6d630e36b0cfeadf10cea14420a3 Mon Sep 17 00:00:00 2001 From: Andreia Ocanoaia Date: Wed, 4 Jun 2025 17:06:31 +0300 Subject: [PATCH 1/3] Let QCow2Container init to pass fh directly as Path Pass the original `fh` parameter directly to QCow2 constructor, relying on QCow2 to handle Path or file-like objects. This allows QCow2 to automatically resolve backing files if they are required. Signed-off-by: Andreia Ocanoaia --- dissect/target/containers/qcow2.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dissect/target/containers/qcow2.py b/dissect/target/containers/qcow2.py index e2eb1a1171..d026baaf10 100644 --- a/dissect/target/containers/qcow2.py +++ b/dissect/target/containers/qcow2.py @@ -22,10 +22,7 @@ def __init__( *args, **kwargs, ): - f = fh - if not hasattr(fh, "read"): - f = fh.open("rb") - self.qcow2 = qcow2.QCow2(f, data_file, backing_file) + self.qcow2 = qcow2.QCow2(fh, data_file, backing_file) super().__init__(fh, self.qcow2.size, *args, **kwargs) From 748cc1cb658269ea070c9889be39e4b7fed9bccc Mon Sep 17 00:00:00 2001 From: Schamper <1254028+Schamper@users.noreply.github.com> Date: Thu, 14 Aug 2025 10:59:38 +0200 Subject: [PATCH 2/3] Compatibility with https://github.com/fox-it/dissect.hypervisor/pull/61 --- dissect/target/containers/qcow2.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dissect/target/containers/qcow2.py b/dissect/target/containers/qcow2.py index d026baaf10..10f8079463 100644 --- a/dissect/target/containers/qcow2.py +++ b/dissect/target/containers/qcow2.py @@ -18,11 +18,12 @@ def __init__( self, fh: BinaryIO | Path, data_file: BinaryIO | None = None, - backing_file: BinaryIO | int | None = None, + backing_file: BinaryIO | None = None, *args, **kwargs, ): self.qcow2 = qcow2.QCow2(fh, data_file, backing_file) + self.stream = self.qcow2.open() super().__init__(fh, self.qcow2.size, *args, **kwargs) @@ -35,13 +36,13 @@ def detect_path(path: Path, original: list | BinaryIO) -> bool: return path.suffix.lower() == ".qcow2" def read(self, length: int) -> bytes: - return self.qcow2.read(length) + return self.stream.read(length) def seek(self, offset: int, whence: int = io.SEEK_SET) -> int: - return self.qcow2.seek(offset, whence) + return self.stream.seek(offset, whence) def tell(self) -> int: - return self.qcow2.tell() + return self.stream.tell() def close(self) -> None: - pass + self.stream.close() From b5522d9365e30abd1d154fbb043438dad164bc21 Mon Sep 17 00:00:00 2001 From: Schamper <1254028+Schamper@users.noreply.github.com> Date: Thu, 14 Aug 2025 11:01:44 +0200 Subject: [PATCH 3/3] Update dependencies --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fe34cf87b3..bfd74f2fc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "dissect.cstruct>=4,<5", "dissect.eventlog>=3,<4", "dissect.evidence>=3,<4", - "dissect.hypervisor>=3,<4", + "dissect.hypervisor>=3.19.dev2,<4", # TODO: update on release! "dissect.ntfs>=3.4,<4", "dissect.regf>=3.13,<4", "dissect.util>=3,<4", @@ -95,13 +95,13 @@ dev = [ "dissect.fat[dev]>=3.0.dev,<4.0.dev", "dissect.ffs[dev]>=3.0.dev,<4.0.dev", "dissect.fve[dev]>=4.2.dev,<5.0.dev; platform_system != 'Windows' or platform_python_implementation != 'PyPy'", - "dissect.hypervisor[dev]>=3.0.dev,<4.0.dev", + "dissect.hypervisor[dev]>=3.19.dev,<4.0.dev", "dissect.jffs[dev]>=1.5.dev,<2.0.dev", "dissect.ntfs[dev]>=3.4.dev,<4.0.dev", "dissect.qnxfs[dev]>=1.0.dev,<2.0.dev", "dissect.regf[dev]>=3.13.dev,<4.0.dev", "dissect.shellitem[dev]>=3.0.dev,<4.0.dev", - "dissect.sql[dev]>=3.0.dev,<4.0.dev", + "dissect.sql[dev]>=3.12.dev,<4.0.dev", "dissect.squashfs[dev]>=1.0.dev,<2.0.dev", "dissect.thumbcache[dev]>=1.0.dev,<2.0.dev", "dissect.util>=3.0.dev,<4.0.dev",