diff --git a/dissect/target/containers/qcow2.py b/dissect/target/containers/qcow2.py index e2eb1a1171..10f8079463 100644 --- a/dissect/target/containers/qcow2.py +++ b/dissect/target/containers/qcow2.py @@ -18,14 +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, ): - 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) + self.stream = self.qcow2.open() super().__init__(fh, self.qcow2.size, *args, **kwargs) @@ -38,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() 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",