Research notes / Virtual disk preservation
QCOW2 backups: an unchanged overlay can expose different data
/ Updated / Measured tool behavior and documentation review
A QCOW2 overlay is not necessarily a self-contained disk. In our controlled experiment, replacing its base changed 131,072 guest-visible bytes while the overlay hash stayed identical and qemu-img check still succeeded. Separately, changing one stored payload byte also passed the consistency check.
On this page12 sections
The guest interface is not the image format
Virtio-blk presents a disk; virtio-scsi presents a SCSI host that can address multiple devices. QEMU can attach an image-backed scsi-hd device to that host, without passing through a physical SCSI disk. [22]
These are guest-facing interfaces. QCOW2 instead determines how guest blocks map to stored data and backing files. Our engineering inference: changing the controller alone neither inventories nor flattens the chain, and does not verify its contents. Preserve both the intended device configuration and the resolved image dependencies. [23]
Completion has a cache contract. In the reviewed VIRTIO 1.2 rules, a flush submitted after a completed write must itself complete successfully before its stability guarantee applies, assuming a conforming implementation backed by persistent storage. Some writethrough configurations instead require stability when the write completes. Turning writeback off does not guarantee that older cached writes became persistent. Therefore, neither "every completion is durable" nor "completion can never be durable" is a sound general rule. [21, sections 5.2.5-5.2.6]
QEMU's cache names need unpacking. In QEMU's documented option mapping, cache=none enables direct host I/O but leaves the guest-device writeback setting on and flush suppression off. It does not mean that every cache is disabled. Conversely, cache=unsafe enables flush suppression. Record these settings when interpreting a guest's completion result; the controller name alone does not describe the persistence path. [24]
This source-reviewed distinction adds no VM, crash or performance experiment to the offline image tests below. An image checker and a successful guest write answer different questions; neither alone demonstrates the application recovery required by the backup.
Three meanings of an empty-looking region
QCOW2 maps a virtual disk onto clusters in an image file. An unallocated guest cluster can read from a backing file; without one, it reads as zeros. A standard zero-cluster descriptor explicitly supplies zeros instead of inheriting backing data. The distinction is recorded in metadata, not visible in a plain zero-filled read. [2]
Our fixture is deliberately small: a 256 KiB raw base containing byte 0x11, plus a QCOW2 overlay with 64 KiB clusters. We write 0x22 to the first cluster, explicitly zero the second, and leave the last two inherited. The expected virtual disk is:
| Guest offset | Overlay state | Initial read | After base replacement |
|---|---|---|---|
| 0 KiB | Stored data | 0x22 | 0x22 |
| 64 KiB | Explicit zero | 0x00 | 0x00 |
| 128 KiB | Inherited | 0x11 | 0x33 |
| 192 KiB | Inherited | 0x11 | 0x33 |
Replacing every byte in the base with 0x33 leaves the first two guest clusters unchanged. Only the inherited half changes. This is why a backup inventory needs the backing chain, not just the active overlay's filename and hash.
What the checks actually observed
Each row begins from fresh files. We close every writer before the manipulation, run the tools offline, export the whole virtual disk to raw bytes where possible, and compare it against a separately constructed baseline.
| Case | Overlay hash unchanged? | Check exit | Compare exit | Changed guest bytes |
|---|---|---|---|---|
| Intact chain | Yes | 0 | 0 | 0 |
| Replace base bytes | Yes | 0 | 1 | 131,072 |
| Remove base | Yes | 1 | 2 | Unreadable |
| Move overlay alone | Yes | 1 | 2 | Unreadable |
| Move complete chain | Yes | 0 | 0 | 0 |
| Change one payload byte | No | 0 | 1 | 1 |
| Safe rebase to different base | No | 0 | 0 | 0 |
| Unsafe rebase to different base | No | 0 | 1 | 131,072 |
| Shorten base to 128 KiB | Yes | 0 | 1 | 131,072 |
Missing is not substituted. Removing the base made the check, comparison and full export fail. Moving only the overlay, then deleting the original base, did the same. Moving both files together preserved the virtual disk. We did not observe missing bases silently becoming zeros; that would misdescribe this experiment.
An existing but shortened base behaves differently. In the added case we truncate the raw base from 256 KiB to 128 KiB without touching the overlay. Both inherited clusters now read as zeros: 131,072 guest bytes change, while the overlay hash remains identical and check returns 0. The base still opens; unlike an absent file, its missing tail is covered by the format's zero-fill rule. This is documented behavior, not evidence that a truncated backup is complete. [2]
A valid structure can carry changed data. We located the first stored data extent using qemu-img map --output=json, changed its first byte from 0x22 to 0x23, and left its allocation metadata alone. Check returned 0, but full export and comparison detected exactly one differing guest byte.
The pinned QEMU implementation helps interpret this result: qcow2_check_refcounts reconstructs and compares reference counts and checks copied flags. It is structural evidence, not an expected-content oracle for the guest's files. This code review explains our case; it is not an exhaustive audit of every image checker. [3]
Rebasing changes the dependency. Safe rebase preserved our expected guest bytes by compensating for the different base. Unsafe rebase -u changed the inherited half. Both resulting structures passed check. The documented unsafe mode changes backing metadata without ensuring content equivalence; it is not a shortcut for reconstructing a missing, unknown base. [1]
Reads can populate the overlay
QEMU's optional copy-on-read mode copies inherited data into the overlay's storage when it is read. Unlike copying triggered by guest writes, it can modify the stored image during a workload containing only guest reads. QEMU and libvirt document the mode as disabled by default. [16] [17]
This is not the same as opening the image read-only: QEMU v8.2.2 rejects its copy-on-read opening flag on a read-only block node. [18] The copying implementation can round the affected region to a subcluster boundary, so the read request length is not an exact measure of materialization work. [19]
Enabling the mode alone does not establish that every inherited region has been copied or that the backing contents match a trusted original. These are consequences of the mechanism; a partial-read experiment does not establish a complete recovery image. Record the opening mode, preserve remaining dependencies and verify the intended guest contents separately. No copy-on-read performance or application-recovery experiment was run here. [19]
A 512-byte read can change a larger mapping
We exercised eight fresh 256-KiB synthetic images with qemu-io version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18): two layouts, two base patterns and copy-on-read on or off. Each received a 512-byte read at offset 512, followed by the same read again. No guest write or VM was involved. The table reports bytes resolved at the overlay in qemu-img map, not physical writes, allocated host storage or network traffic.
| Layout | Base byte | Copy-on-read | Local bytes before | After first read | After repeat |
|---|---|---|---|---|---|
| Standard, 64-KiB cluster | 0x11 | Off | 0 | 0 | 0 |
| Standard, 64-KiB cluster | 0x11 | On | 0 | 65,536 | 65,536 |
| Standard, 64-KiB cluster | 0x00 | Off | 0 | 0 | 0 |
| Standard, 64-KiB cluster | 0x00 | On | 0 | 65,536 | 65,536 |
| Extended L2, 128-KiB cluster | 0x11 | Off | 0 | 0 | 0 |
| Extended L2, 128-KiB cluster | 0x11 | On | 0 | 4,096 | 4,096 |
| Extended L2, 128-KiB cluster | 0x00 | Off | 0 | 0 | 0 |
| Extended L2, 128-KiB cluster | 0x00 | On | 0 | 4,096 | 4,096 |
Standard copy-on-read resolved 65,536 bytes locally; the extended-L2 configuration resolved 4,096. With zero input, this was a local zero mapping, not evidence that a payload of that size was physically written. QEMU's subcluster handling and the QCOW2 format explain the different mapping granularity. [19] [2]
Every full raw export still matched the independently constructed expected bytes, and each base remained unchanged. The backing filename remained base.raw; the rest of the virtual disk still resolved through it. This checks a controlled read/materialization behavior, not crash durability or the safety of deleting a base.
Command receipts, maps and hashes, the executable probe and evidence-validation tests make the fixture reproducible. Both runs use the same Ubuntu package and host, not independent implementations.
Keep the performance claim attached to its method
Tang's 2011 FVD design combines demand-triggered copying with optional prefetching of untouched regions. Its section 4 PostMark comparison explicitly disabled both features. The reported 249% file-creation advantage in one configuration therefore cannot be cited as a copy-on-read speedup. It is also not a measurement of modern QEMU. [9]
FVD also separates copying from durably recording the copied location. Section 3.2 allows a read-triggered copy without immediately updating the on-disk bitmap: after a host crash, reading the unchanged base can still return the same contents. That argument depends on retaining the identical source; it does not establish permission to delete the base. This is a property of the paper's FVD design, not a claim about QCOW2 metadata persistence or a crash experiment performed here. [9]
QEMU's separate copy-on-read filter can additionally limit copying to an inclusive bottom allocation-bearing node. Reads below that boundary can remain dependent on deeper backing data; this is a source-reviewed configuration boundary, not a mode exercised in our eight fixtures. [20]
Even an equal comparison has a policy
The tenth scenario uses raw files to isolate comparison semantics from QCOW2. One contains 65,536 bytes of 0x11; the other contains the same prefix followed by 65,536 zero bytes. Their sizes and SHA-256 hashes differ. Default qemu-img compare returned 0; strict comparison with -s returned 1.
The default accepts a larger image's zero or unallocated tail. Strict mode rejects size and allocation differences as well as different content. Therefore neither mode should be interpreted as universal backup equivalence. If virtual capacity matters but allocation layout may differ, check capacity separately and compare content. [1]
This is not a hash collision. The tools answer different questions: file identity, format consistency, permitted guest-byte equivalence and intended recovery state. A baseline generated from an already substituted chain would also preserve the wrong state faithfully.
An external data file is not a backing file
A backing file supplies inherited regions. A QCOW2 external data file holds the payload selected by the metadata's mappings. A disk can therefore depend on two files with no backing chain at all. Our additional experiment isolates this case: four 64 KiB clusters, no backing file, and both data_file_raw modes. [2]
Results: changing one payload byte passed check; replacing the payload changed 196,608 guest bytes; shortening it to 128 KiB changed 131,072. The metadata hash stayed unchanged in all three cases. These are executed, synthetic fixtures on qemu-img version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18), not measured production failure rates.
| Case | Info exit | Check exit | Compare exit | Changed guest bytes |
|---|---|---|---|---|
| intact | 0 | 0 | 0 | 0 |
| data-byte-flip | 0 | 0 | 1 | 1 |
| data-replaced | 0 | 0 | 1 | 196,608 |
| data-truncated | 0 | 0 | 1 | 131,072 |
| data-missing | 0 | 1 | 2 | Unreadable |
| metadata-only-moved | 0 | 1 | 2 | Unreadable |
| pair-moved | 0 | 1 | 2 | Unreadable |
| pair-moved-cwd | 0 | 0 | 0 | 0 |
| pair-moved-explicit | 0 | 0 | 0 | 0 |
| runtime-override | 0 | 0 | 1 | 196,608 |
Information is not a dependency read test
After deleting the payload, info --backing-chain --output=json still returned 0 and reported data-file: payload.bin. Reading and checking the disk failed. The name was present in format-specific metadata; it was not a separate backing-chain member. An inventory that only collects backing filenames can therefore omit a required file. The upstream information collector uses a no-I/O opening mode; that source review is separate from our Ubuntu-patched binary observation. [8]
Two identical files can be opened differently
Moving both files into restore/ and running from their former parent still failed in this package. Running from restore/, or explicitly supplying the relocated data-file path, restored the exact baseline. This is a working-directory control, not a claim about every QEMU version or VM manager.
In a separate control, an explicit runtime data-file.filename selected replacement bytes while both original files remained unchanged. The metadata report still named payload.bin. Capture effective opening options as well as stored filenames and hashes. The upstream opening code tries the configured data child before falling back to the header name. [7]
The payload alone need not be the virtual disk
Before any fault injection, we zeroed the second cluster through QEMU. With data_file_raw=off, reading the external file directly still exposed 65,536 old bytes of 0x22; reading through QCOW2 returned zeros. With the flag on, the direct read matched the virtual disk. QEMU's own external-data test documents this zero-write distinction. It is a recovery-interpretation issue, not evidence of secure erasure or physical NAND behavior. [6]
The raw-mode promise does not authenticate a later substituted or edited file. Our out-of-band mutations deliberately violate the initial pairing. Preserve metadata, the resolved payload, relevant opening configuration and an independent guest-content expectation.
The external-data dataset contains all 60 observations, complete command receipts, executable hashes, CSV, code and tests. Repetitions matched; a fresh replay also passed. The original 30 backing-chain and size-control observations remain unchanged. No VM boot, application recovery, crash or live writer was tested.
Keep change tracking aligned with the recovery point
Changed block tracking selects written regions for an incremental backup. A libvirt checkpoint records a tracking boundary, not guest state. Retain the backup payload and its required predecessors; a checkpoint name alone cannot restore the disk. Application quiescing remains a separate decision. [14]
A dirty bitmap marks ranges, not exact changed bytes. In QEMU's documented incremental push workflow, success moves the tracking boundary to backup start, retaining later writes. Failure or cancellation retains the earlier dirty regions plus writes during the attempt. Clearing that history manually can hide work still needed by a retry. [10] This is the on-success policy: QEMU also exposes never and always, so do not assume identical failure behavior for every bitmap-based operation. [11]
Persistent does not mean synchronized after every guest write. QCOW2's in_use flag can identify outdated bitmap contents even when its bitmap metadata remains structurally well formed. [12] Treat tracking validity separately from image readability. Libvirt's documented incremental-backup checks require the bitmap in the active image, a contiguous same-name bitmap subchain, recording state and no inconsistency. Creating a plain overlay does not automatically continue that tracking. [13]
A transaction can launch successfully and still lose a backup job
QEMU's default individual completion mode lets asynchronous jobs finish separately after the transaction is accepted. With on-success bitmap handling, disk A can advance its tracking boundary while disk B fails and retains the older boundary. Keep A's successful incremental: a later incremental for A can depend on it. Acceptance of the launch is not completion of the backup set. [10]
The grouped mode delays successful completion until every participating job is ready and cancels the group if one fails. Actions without support may reject that mode. This coordinates job completion, not application quiescing; it is not evidence of a successful application restore. [15] [14]
Before accepting another incremental, our operational inference is to verify the selected disk, checkpoint lineage, bitmap health and completed backup job. A healthy map still does not authenticate the backup bytes or prove that the guest application can recover. This section reviews QEMU v10.1.0 and libvirt documentation; the QEMU 8.2.2 experiments below did not test dirty bitmaps.
Historical context: separating location from allocation
Tang's 2011 Fast Virtual Disk (FVD) research separates copy-on-write tracking from allocation. This offers useful historical context for asking which metadata answers which question. It is a different format, not evidence that FVD and QCOW2 external data share an implementation or recovery contract. Its PostMark comparison used an older QEMU stack; we do not transfer its speedup to current systems. [9]
Choose the verification boundary
Saltzer, Reed and Clark's End-to-End Arguments in System Design analyzes file transfer across storage, memory and a network. Its receiver reads the destination back and compares a file checksum; reliable transport alone cannot cover the other stages. Lower-layer checks remain useful for reducing retries. [5]
Applied here, our engineering inference is to verify the resolved guest disk against trusted recovery evidence, including its capacity and dependencies. Checking one container file covers a narrower object. Neither the paper nor this byte-pattern experiment establishes application-consistent VM recovery.
A recovery manifest needs dependency identity
Libvirt can obtain chain topology from image metadata or explicit domain configuration. Its documentation emphasizes paths and explicit backing formats, and describes relocation failures. A filename alone is not a content identity; deployment configuration can determine which chain is used. [4]
- Capture the intended state. Record a stable point in time, guest disk capacity, required chain members and external data files, their formats and content identities. For multiple disks, record the consistency procedure; our single-disk test does not establish one.
- Preserve and resolve dependencies. Restore away from the originals. Inventory with
qemu-img info --backing-chain --output=jsonand verify the resolved files against the intended manifest. Inspect format-specific external-data declarations and effective opening options too. Inventory is not authentication or proof that every dependency opens. - Separate structure from contents. Run non-repairing image checks, then verify guest-visible contents against trusted evidence. Keep opening failures distinct from completed checks that report differences.
- Test the required recovery. Check guest filesystem and application state, not merely image readability. An offline raw export can remove this backing dependency, but is not a general export of snapshots, bitmaps, VM configuration or application consistency.
Never modify an image used by a running VM; even concurrent inspection can see inconsistent state. Work on protected copies and keep original evidence before repairs. [1]
This extends backup verification versus restore testing. Compare HDF5 virtual dataset dependencies, where missing sources can yield fill values, and sparse-file allocation, where zero bytes and allocated space are also distinct observations.
Method and reproducibility
Measured with qemu-img version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18); Python 3.12.3. Nine QCOW2 cases plus one raw-size control, three repetitions each: 30 runs on one host. Each exported payload is checked byte for byte, not sampled. The repetitions establish repeatability of these fixtures, not a population failure rate or confidence interval.
The dataset includes column definitions, CSV, raw command results and hashes. Download the Python harness; with qemu-img and qemu-io available:
python3 qcow2-dependencies.py --repetitions 3 > observations.jsonOptional --qemu-img, --qemu-io and --temp-dir arguments select executables and a temporary parent. The runner accepts no existing image, creates private fixtures, uses explicit formats and bounds subprocess waits. Its checks remain active under optimized Python. The table generator verifies coverage, harness identity, command receipts and expected payload hashes before publishing derived rows. Checksums identify the downloaded bytes; they do not authenticate an untrusted observation log.
Limits: uncompressed, unencrypted standard clusters with one raw backing file. We did not boot a VM, simulate a crash, measure performance, test guest filesystems, use live writers, or exercise internal snapshots and persistent dirty bitmaps. The original backing-file experiment excludes external data files; the separate 60-observation supplement above tests them without a backing file. This is a documented behavior demonstration, not a new QEMU vulnerability or a claim that all corruptions pass check. Upstream v8.2.2 source review is separate from the Ubuntu-patched binary tested; executable hashes and its complete package version are retained.
Primary sources
- QEMU 8.2.2: qemu-img check, compare and rebase
- QEMU 8.2.2: QCOW2 image file format, cluster mapping and zero clusters
- QEMU 8.2.2: qcow2_check_refcounts implementation
- libvirt: disk image chains, backing formats and relocation
- Saltzer, Reed and Clark (1984), End-to-End Arguments in System Design, ACM TOCS 2(4), 277-288; author-hosted text
- QEMU v8.2.2 iotest 244: external data, zero writes and raw-mode controls
- QEMU v8.2.2: external data-file opening and creation implementation
- QEMU v8.2.2: image information collection and NO_IO opening
- Chunqiang Tang (2011), FVD: a High-Performance Virtual Machine Image Format for Cloud, USENIX ATC 11
- QEMU v10.1.0: dirty bitmaps, granularity, persistence and incremental backup recovery
- QEMU v10.1.0 QAPI: BitmapSyncMode and BackupCommon
- QEMU v10.1.0 QCOW2 format: bitmap directory and dirty tracking bitmaps
- libvirt: incremental backup internals, checkpoint relationships and bitmap health
- libvirt: domain state capture, quiescing and checkpoint APIs
- QEMU v10.1.0 QAPI: asynchronous transaction completion, individual and grouped modes
- QEMU v8.2.2: copy-on-read drive option and default
- libvirt domain XML: disk driver copy_on_read attribute
- QEMU v8.2.2 block.c: copy-on-read opening checks
- QEMU v8.2.2 block/io.c: bdrv_co_do_copy_on_readv
- QEMU v8.2.2 QAPI: BlockdevOptionsCor and optional bottom boundary
- OASIS VIRTIO 1.2 CS01 (1 July 2022): sections 5.2 and 5.6
- QEMU: Configuring virtio-blk and virtio-scsi Devices (19 January 2021)
- QEMU: An Overview of QEMU Storage Features (14 September 2020)
- QEMU system documentation: cache.direct, cache.no-flush and -drive cache mode mapping
Original sources checked 18 October 2026; external-data sources checked 21 October 2026; change-tracking documentation checked 28 October 2026. Original code and observations: CC0-1.0; upstream materials retain their licenses.