mirror of
https://github.com/Droid-VM/crosvm.git
synced 2026-11-17 06:58:03 +00:00
Three things a phone-hosted qcow2 overlay needs and did not have. A discard over a backing file has to make a ZERO CLUSTER, not zeroes. Without QCOW_OFLAG_ZERO the only way to say "this cluster reads as zeroes even though the backing file has data here" is to allocate a cluster and write zeroes into it, so a guest fstrim over a 32 GB image grows the overlay by 32 GB -- measured, and the reason this exists. With the flag the same fstrim leaves the overlay at 327 MiB. COMPRESSED is tested before ZERO everywhere the pair is matched: a compressed L2 descriptor keeps a byte offset in its low bits, so bit 0 is set for about half of all compressed clusters, and testing ZERO first hands back a freshly zeroed cluster instead of decompressing -- silent data loss. The zstd feature is backed by a C libzstd through an FFI shim rather than the zstd crate. The crate wants a vendored C build of its own; the platform already ships the library, and linking it directly is what lets the compressed-qcow2 path exist in a device build at all. An image with internal snapshots is refused for writing. It is not merely unimplemented: writes never copy a cluster a snapshot still shares, because `file_offset_write` reuses any already-mapped cluster without consulting its refcount, and a refcount rebuild only walks the active L1 table, so clusters reachable only from a snapshot are counted free and handed out again. Reading is unaffected -- the active L1 table is complete on its own -- so such an image still works as a backing file. |
History
|
|
|---|---|---|
| .. | ||
| patches | ||
| src | ||
| Android.bp | ||
| Cargo.toml | ||