src/disk/qcow2.bend checks
raw source on the hub · import 0xe13a97cc62789dc4181c0e4284f7bab6/src/disk/qcow2.bend as Qcow2
3 imports
import Base import ../lib/u64.bend as U import ../lib/bytes.bend as B
Types
type Qcow source · line 25 · raw
Data
Qcow@bits:U32 -> @size:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> @l1:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> @l1_size:U32 -> @rt:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> @rt_clusters:U32 -> @refbits:U32 -> Qcow
type Entry source · line 29 · raw
Data
What an L2 entry says about a cluster.
UnallocEntry
Not in this image: read the backing file (or zeros).
ZeroedEntry
Reads as zeros.
Mapped@off:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> @copied:Bool -> Entry
At host offset off; copied: its reference count is 1.
Packed@off:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> @clen:U32 -> Entry
Compressed: clen bytes of raw deflate at host offset off.
Definitions
def Qcow.magic source · line 40 · raw
U32
"QFI\xfb" read big-endian.
def Qcow.be64 source · line 43 · raw
@+bs:List<&2, U32> -> @+at:Nat -> 0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64
def Qcow.be32 source · line 46 · raw
@+bs:List<&2, U32> -> @+at:Nat -> U32
def Qcow.features_ok source · line 52 · raw
@+version:U32 -> @+bs:List<&2, U32> -> Bool
The feature bits a version 3 header may set: dirty (bit 0) and the compression type (bit 3, which must then be zlib, type 0). Corrupt images, external data files and extended L2 entries are refused.
def Qcow.parse source · line 61 · raw
@+bs:List<&2, U32> -> Maybe<&2, Qcow>
The header of bs (its first 112 bytes or more), if a qcow2 image this device can use: version 2 or 3, clusters of 512 bytes to 2 MiB, no encryption.
def Qcow.writable source · line 72 · raw
@+bs:List<&2, U32> -> Bool
Whether the image may be written: not a qcow2 image, or one that lists no internal snapshot (header byte 60). An internal snapshot shares the image's L2 tables (their L1 entries lose COPIED); writing or discarding through them would change the snapshot too, so such an image is attached read-only.
def Qcow.backing source · line 76 · raw
@+bs:List<&2, U32> -> Pair(0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64, U32)
The backing file name's offset and length (length 0: none).
def Qcow.bits source · line 79 · raw
@q:Qcow -> U32
def Qcow.size source · line 84 · raw
@q:Qcow -> 0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64
def Qcow.csize source · line 89 · raw
@q:Qcow -> U32
def Qcow.inner source · line 93 · raw
@+q:Qcow -> @off:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> U32
The offset of off inside its cluster.
def Qcow.l1_index source · line 97 · raw
@+q:Qcow -> @off:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> U32
off's index in the L1 table (saturating past 2^32 entries).
def Qcow.l2_index source · line 103 · raw
@+q:Qcow -> @off:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> U32
off's index in its L2 table.
def Qcow.entry_off source · line 108 · raw
@e:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> 0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64
The host offset in an L1 or L2 entry (bits 9..55).
def Qcow.decode source · line 112 · raw
@+q:Qcow -> @+e:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> Entry
What an L2 entry says (bit 62 compressed, bit 0 zeros, bit 63 COPIED).
def Qcow.copied source · line 126 · raw
@off:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> 0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64
An L1 or L2 entry for a cluster at off whose reference count is 1.
def Qcow.rt_entries source · line 130 · raw
@+q:Qcow -> U32
The refcount table's entries.
def Qcow.ref_rti source · line 136 · raw
@+q:Qcow -> @h:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> U32
The refcount table index for the cluster at host offset h.
def Qcow.ref_slot source · line 141 · raw
@+q:Qcow -> @h:0xe13a97cc62789dc4181c0e4284f7bab6/src/lib/u64.U64 -> U32
The slot of the cluster at host offset h in its refcount block.