A Swift library for reading QCOW2 disk images (v2 and v3).
Swift port of lima-vm/go-qcow2reader.
- QCOW2 v2 and v3
- Unallocated, standard, and compressed clusters (zlib/raw deflate, zstd)
- Backing file chains
- Extended L2 entries (subcluster bitmaps)
- LRU cache for L2 tables
- Thread-safe reads via
pread(2) - macOS and Linux
import QCOW2
letimage=tryQCOW2Image(url:URL(fileURLWithPath:"disk.qcow2"))print(image.size) // virtual disk size in bytes
letdata=try image.readAt(offset:0, count:512)- Swift 5.9+
- macOS 13+ or Linux
- zlib (system library, always present)
- zstd:
libcompressionon Apple platforms (built-in),libzstdon Linux (apt install libzstd-dev)
.package(url:"https://github.com/inputforge/qcow2", from:"0.1.0")