blob: 01b5250415f0242b58c742ac842735f56cb9173c [file] [log] [blame]
Kevin Wolff7d0fe02009-05-28 16:07:04 +02001/*
2 * Block driver for the QCOW version 2 format
3 *
4 * Copyright (c) 2004-2006 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25#ifndef BLOCK_QCOW2_H
26#define BLOCK_QCOW2_H
27
Daniel P. Berrangeb25b3872017-06-23 17:24:10 +010028#include "crypto/block.h"
Daniel P. Berrange10817bf2015-09-01 14:48:02 +010029#include "qemu/coroutine.h"
Kevin Wolff7d0fe02009-05-28 16:07:04 +020030
Filip Navara14899cd2009-06-23 19:17:30 -050031//#define DEBUG_ALLOC
32//#define DEBUG_ALLOC2
33//#define DEBUG_EXT
34
Kevin Wolff7d0fe02009-05-28 16:07:04 +020035#define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
Kevin Wolff7d0fe02009-05-28 16:07:04 +020036
37#define QCOW_CRYPT_NONE 0
38#define QCOW_CRYPT_AES 1
Daniel P. Berrange4652b8f2017-06-23 17:24:12 +010039#define QCOW_CRYPT_LUKS 2
Kevin Wolff7d0fe02009-05-28 16:07:04 +020040
41#define QCOW_MAX_CRYPT_CLUSTERS 32
Kevin Wolfce48f2f42014-03-26 13:05:45 +010042#define QCOW_MAX_SNAPSHOTS 65536
Kevin Wolff7d0fe02009-05-28 16:07:04 +020043
Kevin Wolf2b5d5952014-03-26 13:05:50 +010044/* 8 MB refcount table is enough for 2 PB images at 64k cluster size
45 * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */
46#define QCOW_MAX_REFTABLE_SIZE 0x800000
47
Kevin Wolf6a83f8b2014-03-26 13:06:06 +010048/* 32 MB L1 table is enough for 2 PB images at 64k cluster size
49 * (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */
50#define QCOW_MAX_L1_SIZE 0x2000000
51
Kevin Wolf5dae6e32014-03-26 13:06:07 +010052/* Allow for an average of 1k per snapshot table entry, should be plenty of
53 * space for snapshot names and IDs */
54#define QCOW_MAX_SNAPSHOTS_SIZE (1024 * QCOW_MAX_SNAPSHOTS)
55
Vladimir Sementsov-Ogievskiy88ddffa2017-06-28 15:05:08 +030056/* Bitmap header extension constraints */
57#define QCOW2_MAX_BITMAPS 65535
58#define QCOW2_MAX_BITMAP_DIRECTORY_SIZE (1024 * QCOW2_MAX_BITMAPS)
59
Kevin Wolff7d0fe02009-05-28 16:07:04 +020060/* indicate that the refcount of the referenced cluster is exactly one. */
Peter Maydell127c84e2013-08-23 17:35:45 +010061#define QCOW_OFLAG_COPIED (1ULL << 63)
Kevin Wolff7d0fe02009-05-28 16:07:04 +020062/* indicate that the cluster is compressed (they never have the copied flag) */
Peter Maydell127c84e2013-08-23 17:35:45 +010063#define QCOW_OFLAG_COMPRESSED (1ULL << 62)
Kevin Wolf6377af42012-03-16 15:02:38 +010064/* The cluster reads as all zeros */
Peter Maydell127c84e2013-08-23 17:35:45 +010065#define QCOW_OFLAG_ZERO (1ULL << 0)
Kevin Wolff7d0fe02009-05-28 16:07:04 +020066
Kevin Wolff7d0fe02009-05-28 16:07:04 +020067#define MIN_CLUSTER_BITS 9
Kevin Wolf80ee15a2009-09-15 12:30:43 +020068#define MAX_CLUSTER_BITS 21
Kevin Wolff7d0fe02009-05-28 16:07:04 +020069
Max Reitz57e21662015-06-01 18:09:17 +020070/* Must be at least 2 to cover COW */
Alberto Garcia1221fe62018-02-05 16:33:36 +020071#define MIN_L2_CACHE_SIZE 2 /* cache entries */
Kevin Wolff7d0fe02009-05-28 16:07:04 +020072
Kevin Wolf29c1a732011-01-10 17:17:28 +010073/* Must be at least 4 to cover all cases of refcount table growth */
Max Reitz440ba082014-08-18 22:07:31 +020074#define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */
75
Max Reitzbc85ef22015-06-01 18:09:19 +020076/* Whichever is more */
77#define DEFAULT_L2_CACHE_CLUSTERS 8 /* clusters */
Max Reitz440ba082014-08-18 22:07:31 +020078#define DEFAULT_L2_CACHE_BYTE_SIZE 1048576 /* bytes */
79
Kevin Wolf99cce9f2011-05-31 15:01:46 +020080#define DEFAULT_CLUSTER_SIZE 65536
81
Kevin Wolfacdfb482013-03-18 13:08:10 +010082
Kevin Wolf64aa99d2013-07-17 14:45:34 +020083#define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts"
84#define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request"
85#define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot"
86#define QCOW2_OPT_DISCARD_OTHER "pass-discard-other"
Max Reitz05de7e82013-10-10 11:09:25 +020087#define QCOW2_OPT_OVERLAP "overlap-check"
Max Reitzee42b5c2014-08-20 19:59:35 +020088#define QCOW2_OPT_OVERLAP_TEMPLATE "overlap-check.template"
Max Reitz05de7e82013-10-10 11:09:25 +020089#define QCOW2_OPT_OVERLAP_MAIN_HEADER "overlap-check.main-header"
90#define QCOW2_OPT_OVERLAP_ACTIVE_L1 "overlap-check.active-l1"
91#define QCOW2_OPT_OVERLAP_ACTIVE_L2 "overlap-check.active-l2"
92#define QCOW2_OPT_OVERLAP_REFCOUNT_TABLE "overlap-check.refcount-table"
93#define QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK "overlap-check.refcount-block"
94#define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE "overlap-check.snapshot-table"
95#define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1"
96#define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2"
Max Reitz6c1c8d52014-08-18 22:07:33 +020097#define QCOW2_OPT_CACHE_SIZE "cache-size"
98#define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size"
Alberto Garcia1221fe62018-02-05 16:33:36 +020099#define QCOW2_OPT_L2_CACHE_ENTRY_SIZE "l2-cache-entry-size"
Max Reitz6c1c8d52014-08-18 22:07:33 +0200100#define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size"
Alberto Garcia279621c2015-08-04 15:14:40 +0300101#define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval"
Kevin Wolfacdfb482013-03-18 13:08:10 +0100102
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200103typedef struct QCowHeader {
104 uint32_t magic;
105 uint32_t version;
106 uint64_t backing_file_offset;
107 uint32_t backing_file_size;
108 uint32_t cluster_bits;
109 uint64_t size; /* in bytes */
110 uint32_t crypt_method;
111 uint32_t l1_size; /* XXX: save number of clusters instead ? */
112 uint64_t l1_table_offset;
113 uint64_t refcount_table_offset;
114 uint32_t refcount_table_clusters;
115 uint32_t nb_snapshots;
116 uint64_t snapshots_offset;
Kevin Wolf6744cba2011-12-15 12:20:58 +0100117
118 /* The following fields are only valid for version >= 3 */
119 uint64_t incompatible_features;
120 uint64_t compatible_features;
121 uint64_t autoclear_features;
122
123 uint32_t refcount_order;
124 uint32_t header_length;
Jeff Codyc4217f62013-09-25 12:08:50 -0400125} QEMU_PACKED QCowHeader;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200126
Kevin Wolfce48f2f42014-03-26 13:05:45 +0100127typedef struct QEMU_PACKED QCowSnapshotHeader {
128 /* header is 8 byte aligned */
129 uint64_t l1_table_offset;
130
131 uint32_t l1_size;
132 uint16_t id_str_size;
133 uint16_t name_size;
134
135 uint32_t date_sec;
136 uint32_t date_nsec;
137
138 uint64_t vm_clock_nsec;
139
140 uint32_t vm_state_size;
141 uint32_t extra_data_size; /* for extension */
142 /* extra data follows */
143 /* id_str follows */
144 /* name follows */
145} QCowSnapshotHeader;
146
147typedef struct QEMU_PACKED QCowSnapshotExtraData {
148 uint64_t vm_state_size_large;
149 uint64_t disk_size;
150} QCowSnapshotExtraData;
151
152
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200153typedef struct QCowSnapshot {
154 uint64_t l1_table_offset;
155 uint32_t l1_size;
156 char *id_str;
157 char *name;
Kevin Wolf90b27752012-04-11 16:33:50 +0200158 uint64_t disk_size;
Kevin Wolfc2c9a462011-11-16 11:35:54 +0100159 uint64_t vm_state_size;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200160 uint32_t date_sec;
161 uint32_t date_nsec;
162 uint64_t vm_clock_nsec;
163} QCowSnapshot;
164
Kevin Wolf49381092011-01-10 17:15:10 +0100165struct Qcow2Cache;
166typedef struct Qcow2Cache Qcow2Cache;
167
Daniel P. Berrange4652b8f2017-06-23 17:24:12 +0100168typedef struct Qcow2CryptoHeaderExtension {
169 uint64_t offset;
170 uint64_t length;
171} QEMU_PACKED Qcow2CryptoHeaderExtension;
172
Kevin Wolf75bab852012-02-02 14:52:08 +0100173typedef struct Qcow2UnknownHeaderExtension {
174 uint32_t magic;
175 uint32_t len;
176 QLIST_ENTRY(Qcow2UnknownHeaderExtension) next;
177 uint8_t data[];
178} Qcow2UnknownHeaderExtension;
179
Kevin Wolfcfcc4c62012-04-12 15:20:27 +0200180enum {
181 QCOW2_FEAT_TYPE_INCOMPATIBLE = 0,
182 QCOW2_FEAT_TYPE_COMPATIBLE = 1,
183 QCOW2_FEAT_TYPE_AUTOCLEAR = 2,
184};
185
Stefan Hajnoczic61d0002012-07-27 09:05:19 +0100186/* Incompatible feature bits */
187enum {
188 QCOW2_INCOMPAT_DIRTY_BITNR = 0,
Max Reitz69c98722013-08-30 14:34:24 +0200189 QCOW2_INCOMPAT_CORRUPT_BITNR = 1,
Stefan Hajnoczic61d0002012-07-27 09:05:19 +0100190 QCOW2_INCOMPAT_DIRTY = 1 << QCOW2_INCOMPAT_DIRTY_BITNR,
Max Reitz69c98722013-08-30 14:34:24 +0200191 QCOW2_INCOMPAT_CORRUPT = 1 << QCOW2_INCOMPAT_CORRUPT_BITNR,
Stefan Hajnoczic61d0002012-07-27 09:05:19 +0100192
Max Reitz69c98722013-08-30 14:34:24 +0200193 QCOW2_INCOMPAT_MASK = QCOW2_INCOMPAT_DIRTY
194 | QCOW2_INCOMPAT_CORRUPT,
Stefan Hajnoczic61d0002012-07-27 09:05:19 +0100195};
196
Stefan Hajnoczibfe80432012-07-27 09:05:22 +0100197/* Compatible feature bits */
198enum {
199 QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR = 0,
200 QCOW2_COMPAT_LAZY_REFCOUNTS = 1 << QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR,
201
202 QCOW2_COMPAT_FEAT_MASK = QCOW2_COMPAT_LAZY_REFCOUNTS,
203};
204
Vladimir Sementsov-Ogievskiy88ddffa2017-06-28 15:05:08 +0300205/* Autoclear feature bits */
206enum {
207 QCOW2_AUTOCLEAR_BITMAPS_BITNR = 0,
208 QCOW2_AUTOCLEAR_BITMAPS = 1 << QCOW2_AUTOCLEAR_BITMAPS_BITNR,
209
210 QCOW2_AUTOCLEAR_MASK = QCOW2_AUTOCLEAR_BITMAPS,
211};
212
Kevin Wolf6cfcb9b2013-06-19 13:44:18 +0200213enum qcow2_discard_type {
214 QCOW2_DISCARD_NEVER = 0,
215 QCOW2_DISCARD_ALWAYS,
216 QCOW2_DISCARD_REQUEST,
217 QCOW2_DISCARD_SNAPSHOT,
218 QCOW2_DISCARD_OTHER,
219 QCOW2_DISCARD_MAX
220};
221
Kevin Wolfcfcc4c62012-04-12 15:20:27 +0200222typedef struct Qcow2Feature {
223 uint8_t type;
224 uint8_t bit;
225 char name[46];
226} QEMU_PACKED Qcow2Feature;
227
Kevin Wolf0b919fa2013-06-19 13:44:20 +0200228typedef struct Qcow2DiscardRegion {
229 BlockDriverState *bs;
230 uint64_t offset;
231 uint64_t bytes;
232 QTAILQ_ENTRY(Qcow2DiscardRegion) next;
233} Qcow2DiscardRegion;
234
Max Reitz7453c962015-02-10 15:28:50 -0500235typedef uint64_t Qcow2GetRefcountFunc(const void *refcount_array,
236 uint64_t index);
237typedef void Qcow2SetRefcountFunc(void *refcount_array,
238 uint64_t index, uint64_t value);
239
Vladimir Sementsov-Ogievskiy88ddffa2017-06-28 15:05:08 +0300240typedef struct Qcow2BitmapHeaderExt {
241 uint32_t nb_bitmaps;
242 uint32_t reserved32;
243 uint64_t bitmap_directory_size;
244 uint64_t bitmap_directory_offset;
245} QEMU_PACKED Qcow2BitmapHeaderExt;
246
Kevin Wolfff991292015-09-07 17:12:56 +0200247typedef struct BDRVQcow2State {
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200248 int cluster_bits;
249 int cluster_size;
250 int cluster_sectors;
Alberto Garcia3c2e5112018-02-05 16:33:13 +0200251 int l2_slice_size;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200252 int l2_bits;
253 int l2_size;
254 int l1_size;
255 int l1_vm_state_index;
Max Reitz1d13d652014-10-22 14:09:28 +0200256 int refcount_block_bits;
257 int refcount_block_size;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200258 int csize_shift;
259 int csize_mask;
260 uint64_t cluster_offset_mask;
261 uint64_t l1_table_offset;
262 uint64_t *l1_table;
Kevin Wolf29c1a732011-01-10 17:17:28 +0100263
264 Qcow2Cache* l2_table_cache;
265 Qcow2Cache* refcount_block_cache;
Alberto Garcia279621c2015-08-04 15:14:40 +0300266 QEMUTimer *cache_clean_timer;
267 unsigned cache_clean_interval;
Kevin Wolf29c1a732011-01-10 17:17:28 +0100268
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200269 uint8_t *cluster_cache;
270 uint8_t *cluster_data;
271 uint64_t cluster_cache_offset;
Blue Swirl72cf2d42009-09-12 07:36:22 +0000272 QLIST_HEAD(QCowClusterAlloc, QCowL2Meta) cluster_allocs;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200273
274 uint64_t *refcount_table;
275 uint64_t refcount_table_offset;
276 uint32_t refcount_table_size;
Alberto Garcia7061a072017-02-01 14:38:28 +0200277 uint32_t max_refcount_table_index; /* Last used entry in refcount_table */
Kevin Wolfbb572ae2014-03-26 13:05:51 +0100278 uint64_t free_cluster_index;
279 uint64_t free_byte_offset;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200280
Kevin Wolf68d100e2011-06-30 17:42:09 +0200281 CoMutex lock;
282
Daniel P. Berrange4652b8f2017-06-23 17:24:12 +0100283 Qcow2CryptoHeaderExtension crypto_header; /* QCow2 header extension */
Daniel P. Berrangeb25b3872017-06-23 17:24:10 +0100284 QCryptoBlockOpenOptions *crypto_opts; /* Disk encryption runtime options */
285 QCryptoBlock *crypto; /* Disk encryption format driver */
Daniel P. Berrange4652b8f2017-06-23 17:24:12 +0100286 bool crypt_physical_offset; /* Whether to use virtual or physical offset
287 for encryption initialization vector tweak */
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200288 uint32_t crypt_method_header;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200289 uint64_t snapshots_offset;
290 int snapshots_size;
Kevin Wolfce48f2f42014-03-26 13:05:45 +0100291 unsigned int nb_snapshots;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200292 QCowSnapshot *snapshots;
Anthony Liguori06d92602011-11-14 15:09:46 -0600293
Vladimir Sementsov-Ogievskiy88ddffa2017-06-28 15:05:08 +0300294 uint32_t nb_bitmaps;
295 uint64_t bitmap_directory_size;
296 uint64_t bitmap_directory_offset;
Vladimir Sementsov-Ogievskiy605bc8b2018-04-11 15:26:05 +0300297 bool dirty_bitmaps_loaded;
Vladimir Sementsov-Ogievskiy88ddffa2017-06-28 15:05:08 +0300298
Anthony Liguori06d92602011-11-14 15:09:46 -0600299 int flags;
Kevin Wolf6744cba2011-12-15 12:20:58 +0100300 int qcow_version;
Kevin Wolf74c45102013-03-15 10:35:08 +0100301 bool use_lazy_refcounts;
Max Reitzb6481f32013-09-03 10:09:53 +0200302 int refcount_order;
Max Reitz346a53d2015-02-10 15:28:43 -0500303 int refcount_bits;
304 uint64_t refcount_max;
Kevin Wolf6744cba2011-12-15 12:20:58 +0100305
Max Reitz7453c962015-02-10 15:28:50 -0500306 Qcow2GetRefcountFunc *get_refcount;
307 Qcow2SetRefcountFunc *set_refcount;
308
Kevin Wolf67af6742013-06-19 13:44:19 +0200309 bool discard_passthrough[QCOW2_DISCARD_MAX];
310
Max Reitz3e355392013-10-10 11:09:24 +0200311 int overlap_check; /* bitmask of Qcow2MetadataOverlap values */
Max Reitz85186eb2014-09-05 16:07:16 +0200312 bool signaled_corruption;
Max Reitz3e355392013-10-10 11:09:24 +0200313
Kevin Wolf6744cba2011-12-15 12:20:58 +0100314 uint64_t incompatible_features;
315 uint64_t compatible_features;
316 uint64_t autoclear_features;
317
318 size_t unknown_header_fields_size;
319 void* unknown_header_fields;
Kevin Wolf75bab852012-02-02 14:52:08 +0100320 QLIST_HEAD(, Qcow2UnknownHeaderExtension) unknown_header_ext;
Kevin Wolf0b919fa2013-06-19 13:44:20 +0200321 QTAILQ_HEAD (, Qcow2DiscardRegion) discards;
322 bool cache_discards;
Kevin Wolfe4603fe2015-04-07 15:03:16 +0200323
324 /* Backing file path and format as stored in the image (this is not the
325 * effective path/format, which may be the result of a runtime option
326 * override) */
327 char *image_backing_file;
328 char *image_backing_format;
Kevin Wolfff991292015-09-07 17:12:56 +0200329} BDRVQcow2State;
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200330
Kevin Wolf593fb832012-12-07 18:08:43 +0100331typedef struct Qcow2COWRegion {
332 /**
333 * Offset of the COW region in bytes from the start of the first cluster
334 * touched by the request.
335 */
Alberto Garciae034f5b2017-06-19 16:40:03 +0300336 unsigned offset;
Kevin Wolf593fb832012-12-07 18:08:43 +0100337
Kevin Wolf85567392016-06-01 14:08:56 +0200338 /** Number of bytes to copy */
Alberto Garciae034f5b2017-06-19 16:40:03 +0300339 unsigned nb_bytes;
Kevin Wolf593fb832012-12-07 18:08:43 +0100340} Qcow2COWRegion;
341
Kevin Wolff50f88b2012-12-07 18:08:46 +0100342/**
343 * Describes an in-flight (part of a) write request that writes to clusters
344 * that are not referenced in their L2 table yet.
345 */
Kevin Wolf45aba422009-05-28 16:07:05 +0200346typedef struct QCowL2Meta
347{
Kevin Wolf1d3afd62012-12-07 18:08:42 +0100348 /** Guest offset of the first newly allocated cluster */
Kevin Wolf45aba422009-05-28 16:07:05 +0200349 uint64_t offset;
Kevin Wolf1d3afd62012-12-07 18:08:42 +0100350
Kevin Wolf1d3afd62012-12-07 18:08:42 +0100351 /** Host offset of the first newly allocated cluster */
Kevin Wolf250196f2012-03-02 14:10:54 +0100352 uint64_t alloc_offset;
Kevin Wolf1d3afd62012-12-07 18:08:42 +0100353
Kevin Wolf1d3afd62012-12-07 18:08:42 +0100354 /** Number of newly allocated clusters */
Kevin Wolf45aba422009-05-28 16:07:05 +0200355 int nb_clusters;
Kevin Wolf1d3afd62012-12-07 18:08:42 +0100356
Max Reitz564a6b62017-05-04 01:11:18 +0200357 /** Do not free the old clusters */
358 bool keep_old_clusters;
359
Kevin Wolf1d3afd62012-12-07 18:08:42 +0100360 /**
361 * Requests that overlap with this allocation and wait to be restarted
362 * when the allocating request has completed.
363 */
Kevin Wolf68d100e2011-06-30 17:42:09 +0200364 CoQueue dependent_requests;
Kevin Wolff2149782009-08-31 16:48:49 +0200365
Kevin Wolf593fb832012-12-07 18:08:43 +0100366 /**
367 * The COW Region between the start of the first allocated cluster and the
368 * area the guest actually writes to.
369 */
370 Qcow2COWRegion cow_start;
371
372 /**
373 * The COW Region between the area the guest actually writes to and the
374 * end of the last allocated cluster.
375 */
376 Qcow2COWRegion cow_end;
377
Alberto Garciaee22a9d2017-06-19 16:40:08 +0300378 /**
379 * The I/O vector with the data from the actual guest write request.
380 * If non-NULL, this is meant to be merged together with the data
381 * from @cow_start and @cow_end into one single write operation.
382 */
383 QEMUIOVector *data_qiov;
384
Kevin Wolf88c65882013-03-26 17:50:11 +0100385 /** Pointer to next L2Meta of the same write request */
386 struct QCowL2Meta *next;
387
Blue Swirl72cf2d42009-09-12 07:36:22 +0000388 QLIST_ENTRY(QCowL2Meta) next_in_flight;
Kevin Wolf45aba422009-05-28 16:07:05 +0200389} QCowL2Meta;
390
Eric Blake3ef95212017-05-06 19:05:45 -0500391typedef enum QCow2ClusterType {
Kevin Wolf68d000a2012-03-14 19:15:03 +0100392 QCOW2_CLUSTER_UNALLOCATED,
Eric Blakefdfab372017-05-06 19:05:46 -0500393 QCOW2_CLUSTER_ZERO_PLAIN,
394 QCOW2_CLUSTER_ZERO_ALLOC,
Kevin Wolf68d000a2012-03-14 19:15:03 +0100395 QCOW2_CLUSTER_NORMAL,
396 QCOW2_CLUSTER_COMPRESSED,
Eric Blake3ef95212017-05-06 19:05:45 -0500397} QCow2ClusterType;
Kevin Wolf68d000a2012-03-14 19:15:03 +0100398
Max Reitza40f1c22013-08-30 14:34:25 +0200399typedef enum QCow2MetadataOverlap {
400 QCOW2_OL_MAIN_HEADER_BITNR = 0,
401 QCOW2_OL_ACTIVE_L1_BITNR = 1,
402 QCOW2_OL_ACTIVE_L2_BITNR = 2,
403 QCOW2_OL_REFCOUNT_TABLE_BITNR = 3,
404 QCOW2_OL_REFCOUNT_BLOCK_BITNR = 4,
405 QCOW2_OL_SNAPSHOT_TABLE_BITNR = 5,
406 QCOW2_OL_INACTIVE_L1_BITNR = 6,
407 QCOW2_OL_INACTIVE_L2_BITNR = 7,
408
409 QCOW2_OL_MAX_BITNR = 8,
410
411 QCOW2_OL_NONE = 0,
412 QCOW2_OL_MAIN_HEADER = (1 << QCOW2_OL_MAIN_HEADER_BITNR),
413 QCOW2_OL_ACTIVE_L1 = (1 << QCOW2_OL_ACTIVE_L1_BITNR),
414 QCOW2_OL_ACTIVE_L2 = (1 << QCOW2_OL_ACTIVE_L2_BITNR),
415 QCOW2_OL_REFCOUNT_TABLE = (1 << QCOW2_OL_REFCOUNT_TABLE_BITNR),
416 QCOW2_OL_REFCOUNT_BLOCK = (1 << QCOW2_OL_REFCOUNT_BLOCK_BITNR),
417 QCOW2_OL_SNAPSHOT_TABLE = (1 << QCOW2_OL_SNAPSHOT_TABLE_BITNR),
418 QCOW2_OL_INACTIVE_L1 = (1 << QCOW2_OL_INACTIVE_L1_BITNR),
419 /* NOTE: Checking overlaps with inactive L2 tables will result in bdrv
420 * reads. */
421 QCOW2_OL_INACTIVE_L2 = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
422} QCow2MetadataOverlap;
423
Max Reitz4a273c32013-10-10 11:09:27 +0200424/* Perform all overlap checks which can be done in constant time */
425#define QCOW2_OL_CONSTANT \
426 (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE | \
427 QCOW2_OL_SNAPSHOT_TABLE)
428
Max Reitza40f1c22013-08-30 14:34:25 +0200429/* Perform all overlap checks which don't require disk access */
430#define QCOW2_OL_CACHED \
Max Reitz4a273c32013-10-10 11:09:27 +0200431 (QCOW2_OL_CONSTANT | QCOW2_OL_ACTIVE_L2 | QCOW2_OL_REFCOUNT_BLOCK | \
432 QCOW2_OL_INACTIVE_L1)
433
434/* Perform all overlap checks */
435#define QCOW2_OL_ALL \
436 (QCOW2_OL_CACHED | QCOW2_OL_INACTIVE_L2)
Max Reitza40f1c22013-08-30 14:34:25 +0200437
Hu Tao46bae922014-01-21 11:30:02 +0800438#define L1E_OFFSET_MASK 0x00fffffffffffe00ULL
439#define L2E_OFFSET_MASK 0x00fffffffffffe00ULL
Kevin Wolf68d000a2012-03-14 19:15:03 +0100440#define L2E_COMPRESSED_OFFSET_SIZE_MASK 0x3fffffffffffffffULL
441
Hu Tao46bae922014-01-21 11:30:02 +0800442#define REFT_OFFSET_MASK 0xfffffffffffffe00ULL
Kevin Wolf76dc9e02012-03-16 14:09:08 +0100443
Kevin Wolfff991292015-09-07 17:12:56 +0200444static inline int64_t start_of_cluster(BDRVQcow2State *s, int64_t offset)
Kevin Wolf3b8e2e22013-03-26 17:50:02 +0100445{
446 return offset & ~(s->cluster_size - 1);
447}
448
Kevin Wolfff991292015-09-07 17:12:56 +0200449static inline int64_t offset_into_cluster(BDRVQcow2State *s, int64_t offset)
Kevin Wolfc37f4cd2013-03-26 17:50:03 +0100450{
451 return offset & (s->cluster_size - 1);
452}
453
Max Reitzb6d36de2015-09-14 16:39:47 +0200454static inline uint64_t size_to_clusters(BDRVQcow2State *s, uint64_t size)
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200455{
456 return (size + (s->cluster_size - 1)) >> s->cluster_bits;
457}
458
Kevin Wolfff991292015-09-07 17:12:56 +0200459static inline int64_t size_to_l1(BDRVQcow2State *s, int64_t size)
Stefan Hajnoczi419b19d2010-04-28 11:36:11 +0100460{
461 int shift = s->cluster_bits + s->l2_bits;
462 return (size + (1ULL << shift) - 1) >> shift;
463}
464
Alberto Garcia05b5b6e2018-02-05 16:33:12 +0200465static inline int offset_to_l1_index(BDRVQcow2State *s, uint64_t offset)
466{
467 return offset >> (s->l2_bits + s->cluster_bits);
468}
469
Kevin Wolfff991292015-09-07 17:12:56 +0200470static inline int offset_to_l2_index(BDRVQcow2State *s, int64_t offset)
Kevin Wolf17a71e52013-03-26 17:49:56 +0100471{
472 return (offset >> s->cluster_bits) & (s->l2_size - 1);
473}
474
Alberto Garcia8f818172018-02-05 16:33:14 +0200475static inline int offset_to_l2_slice_index(BDRVQcow2State *s, int64_t offset)
476{
477 return (offset >> s->cluster_bits) & (s->l2_slice_size - 1);
478}
479
Kevin Wolfff991292015-09-07 17:12:56 +0200480static inline int64_t qcow2_vm_state_offset(BDRVQcow2State *s)
Kevin Wolf1ebf5612013-09-06 12:20:08 +0200481{
482 return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits);
483}
484
Eric Blake3ef95212017-05-06 19:05:45 -0500485static inline QCow2ClusterType qcow2_get_cluster_type(uint64_t l2_entry)
Kevin Wolf68d000a2012-03-14 19:15:03 +0100486{
487 if (l2_entry & QCOW_OFLAG_COMPRESSED) {
488 return QCOW2_CLUSTER_COMPRESSED;
Kevin Wolf6377af42012-03-16 15:02:38 +0100489 } else if (l2_entry & QCOW_OFLAG_ZERO) {
Eric Blakefdfab372017-05-06 19:05:46 -0500490 if (l2_entry & L2E_OFFSET_MASK) {
491 return QCOW2_CLUSTER_ZERO_ALLOC;
492 }
493 return QCOW2_CLUSTER_ZERO_PLAIN;
Kevin Wolf68d000a2012-03-14 19:15:03 +0100494 } else if (!(l2_entry & L2E_OFFSET_MASK)) {
495 return QCOW2_CLUSTER_UNALLOCATED;
496 } else {
497 return QCOW2_CLUSTER_NORMAL;
498 }
499}
500
Stefan Hajnoczibfe80432012-07-27 09:05:22 +0100501/* Check whether refcounts are eager or lazy */
Kevin Wolfff991292015-09-07 17:12:56 +0200502static inline bool qcow2_need_accurate_refcounts(BDRVQcow2State *s)
Stefan Hajnoczibfe80432012-07-27 09:05:22 +0100503{
504 return !(s->incompatible_features & QCOW2_INCOMPAT_DIRTY);
505}
Kevin Wolfc1424422009-05-28 16:07:06 +0200506
Kevin Wolf65eb2e32013-03-26 17:49:58 +0100507static inline uint64_t l2meta_cow_start(QCowL2Meta *m)
508{
509 return m->offset + m->cow_start.offset;
510}
511
512static inline uint64_t l2meta_cow_end(QCowL2Meta *m)
513{
Kevin Wolf85567392016-06-01 14:08:56 +0200514 return m->offset + m->cow_end.offset + m->cow_end.nb_bytes;
Kevin Wolf65eb2e32013-03-26 17:49:58 +0100515}
516
Max Reitz0e065282015-02-10 15:28:48 -0500517static inline uint64_t refcount_diff(uint64_t r1, uint64_t r2)
Max Reitz2aabe7c2015-02-10 15:28:47 -0500518{
519 return r1 > r2 ? r1 - r2 : r2 - r1;
520}
521
Pavel Butsykin46b732c2017-09-18 15:42:29 +0300522static inline
523uint32_t offset_to_reftable_index(BDRVQcow2State *s, uint64_t offset)
524{
525 return offset >> (s->refcount_block_bits + s->cluster_bits);
526}
527
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200528/* qcow2.c functions */
Max Reitz12cc30a2017-06-13 22:21:03 +0200529int64_t qcow2_refcount_metadata_size(int64_t clusters, size_t cluster_size,
530 int refcount_order, bool generous_increase,
531 uint64_t *refblock_count);
532
Kevin Wolf280d3732012-12-07 18:08:47 +0100533int qcow2_mark_dirty(BlockDriverState *bs);
Max Reitz69c98722013-08-30 14:34:24 +0200534int qcow2_mark_corrupt(BlockDriverState *bs);
535int qcow2_mark_consistent(BlockDriverState *bs);
Kevin Wolfe24e49e2012-02-02 12:32:31 +0100536int qcow2_update_header(BlockDriverState *bs);
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200537
Max Reitz85186eb2014-09-05 16:07:16 +0200538void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
539 int64_t size, const char *message_format, ...)
540 GCC_FMT_ATTR(5, 6);
541
Alberto Garcia0cf0e592018-03-06 18:14:06 +0200542int qcow2_validate_table(BlockDriverState *bs, uint64_t offset,
543 uint64_t entries, size_t entry_len,
544 int64_t max_size_bytes, const char *table_name,
545 Error **errp);
546
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200547/* qcow2-refcount.c functions */
Kevin Wolfed6ccf02009-05-28 16:07:07 +0200548int qcow2_refcount_init(BlockDriverState *bs);
549void qcow2_refcount_close(BlockDriverState *bs);
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200550
Max Reitz7324c102015-02-10 15:28:46 -0500551int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index,
Max Reitz0e065282015-02-10 15:28:48 -0500552 uint64_t *refcount);
Max Reitz44751912014-10-27 11:12:54 +0100553
Max Reitz32b64442013-09-03 10:09:52 +0200554int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index,
Max Reitz0e065282015-02-10 15:28:48 -0500555 uint64_t addend, bool decrease,
Max Reitz2aabe7c2015-02-10 15:28:47 -0500556 enum qcow2_discard_type type);
Max Reitz32b64442013-09-03 10:09:52 +0200557
Max Reitz772d1f92017-06-13 22:21:05 +0200558int64_t qcow2_refcount_area(BlockDriverState *bs, uint64_t offset,
559 uint64_t additional_clusters, bool exact_size,
560 int new_refblock_index,
561 uint64_t new_refblock_offset);
562
Kevin Wolfbb572ae2014-03-26 13:05:51 +0100563int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size);
Max Reitzb6d36de2015-09-14 16:39:47 +0200564int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
565 int64_t nb_clusters);
Kevin Wolfed6ccf02009-05-28 16:07:07 +0200566int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size);
567void qcow2_free_clusters(BlockDriverState *bs,
Kevin Wolf6cfcb9b2013-06-19 13:44:18 +0200568 int64_t offset, int64_t size,
569 enum qcow2_discard_type type);
570void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry,
571 int nb_clusters, enum qcow2_discard_type type);
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200572
Kevin Wolfed6ccf02009-05-28 16:07:07 +0200573int qcow2_update_snapshot_refcount(BlockDriverState *bs,
574 int64_t l1_table_offset, int l1_size, int addend);
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200575
Paolo Bonzini8b220eb2018-03-01 17:36:14 +0100576int coroutine_fn qcow2_flush_caches(BlockDriverState *bs);
577int coroutine_fn qcow2_write_caches(BlockDriverState *bs);
Kevin Wolf166acf52012-05-11 18:18:36 +0200578int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
579 BdrvCheckMode fix);
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200580
Kevin Wolf0b919fa2013-06-19 13:44:20 +0200581void qcow2_process_discards(BlockDriverState *bs, int ret);
582
Max Reitz231bb262013-10-10 11:09:23 +0200583int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset,
Max Reitza40f1c22013-08-30 14:34:25 +0200584 int64_t size);
Max Reitz231bb262013-10-10 11:09:23 +0200585int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
Max Reitza40f1c22013-08-30 14:34:25 +0200586 int64_t size);
Vladimir Sementsov-Ogievskiy8a5bb1f2017-06-28 15:05:07 +0300587int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res,
588 void **refcount_table,
589 int64_t *refcount_table_size,
590 int64_t offset, int64_t size);
Max Reitza40f1c22013-08-30 14:34:25 +0200591
Max Reitz791c9a02015-07-27 17:51:37 +0200592int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
593 BlockDriverAmendStatusCB *status_cb,
594 void *cb_opaque, Error **errp);
Pavel Butsykin46b732c2017-09-18 15:42:29 +0300595int qcow2_shrink_reftable(BlockDriverState *bs);
Pavel Butsykin163bc392017-09-29 15:16:13 +0300596int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);
Max Reitz791c9a02015-07-27 17:51:37 +0200597
Kevin Wolf45aba422009-05-28 16:07:05 +0200598/* qcow2-cluster.c functions */
Kevin Wolf2cf7cfa2013-05-14 16:14:33 +0200599int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
600 bool exact_size);
Pavel Butsykin46b732c2017-09-18 15:42:29 +0300601int qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t max_size);
Max Reitze23e4002013-08-30 14:34:28 +0200602int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index);
Kevin Wolf66f82ce2010-04-14 14:17:38 +0200603int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset);
Kevin Wolfff991292015-09-07 17:12:56 +0200604int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num,
Daniel P. Berrange446d3062017-06-23 17:24:09 +0100605 uint8_t *buf, int nb_sectors, bool enc, Error **errp);
Kevin Wolf45aba422009-05-28 16:07:05 +0200606
Kevin Wolf1c46efa2010-05-21 17:59:36 +0200607int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
Kevin Wolfecfe1862016-05-31 16:13:07 +0200608 unsigned int *bytes, uint64_t *cluster_offset);
Kevin Wolff4f0d392010-02-02 15:20:57 +0100609int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
Kevin Wolfd46a0bb2016-06-01 16:55:05 +0200610 unsigned int *bytes, uint64_t *host_offset,
611 QCowL2Meta **m);
Kevin Wolfed6ccf02009-05-28 16:07:07 +0200612uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
Kevin Wolf45aba422009-05-28 16:07:05 +0200613 uint64_t offset,
614 int compressed_size);
615
Kevin Wolf148da7e2010-01-20 15:03:01 +0100616int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
Eric Blaked2cb36a2017-05-06 19:05:52 -0500617int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset,
618 uint64_t bytes, enum qcow2_discard_type type,
619 bool full_discard);
620int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset,
621 uint64_t bytes, int flags);
Kevin Wolf45aba422009-05-28 16:07:05 +0200622
Max Reitz4057a2b2014-10-27 11:12:53 +0100623int qcow2_expand_zero_clusters(BlockDriverState *bs,
Max Reitz8b139762015-07-27 17:51:32 +0200624 BlockDriverAmendStatusCB *status_cb,
625 void *cb_opaque);
Max Reitz32b64442013-09-03 10:09:52 +0200626
Kevin Wolfc1424422009-05-28 16:07:06 +0200627/* qcow2-snapshot.c functions */
Kevin Wolfed6ccf02009-05-28 16:07:07 +0200628int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info);
629int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id);
Wenchao Xiaa89d89d2013-09-11 14:04:33 +0800630int qcow2_snapshot_delete(BlockDriverState *bs,
631 const char *snapshot_id,
632 const char *name,
633 Error **errp);
Kevin Wolfed6ccf02009-05-28 16:07:07 +0200634int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab);
Wenchao Xia7b4c4782013-12-04 17:10:54 +0800635int qcow2_snapshot_load_tmp(BlockDriverState *bs,
636 const char *snapshot_id,
637 const char *name,
638 Error **errp);
Kevin Wolfc1424422009-05-28 16:07:06 +0200639
Kevin Wolfed6ccf02009-05-28 16:07:07 +0200640void qcow2_free_snapshots(BlockDriverState *bs);
641int qcow2_read_snapshots(BlockDriverState *bs);
Kevin Wolfc1424422009-05-28 16:07:06 +0200642
Kevin Wolf49381092011-01-10 17:15:10 +0100643/* qcow2-cache.c functions */
Alberto Garcia1221fe62018-02-05 16:33:36 +0200644Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables,
645 unsigned table_size);
Alberto Garciae64d4072018-02-05 16:33:08 +0200646int qcow2_cache_destroy(Qcow2Cache *c);
Kevin Wolf49381092011-01-10 17:15:10 +0100647
Alberto Garcia2d135ee2018-02-05 16:33:06 +0200648void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table);
Kevin Wolf49381092011-01-10 17:15:10 +0100649int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c);
Denis V. Lunevf3c3b872016-06-02 18:58:15 +0300650int qcow2_cache_write(BlockDriverState *bs, Qcow2Cache *c);
Kevin Wolf49381092011-01-10 17:15:10 +0100651int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c,
652 Qcow2Cache *dependency);
Kevin Wolf3de0a292011-01-14 15:55:38 +0100653void qcow2_cache_depends_on_flush(Qcow2Cache *c);
Kevin Wolf49381092011-01-10 17:15:10 +0100654
Alberto Garciab2f68bf2018-02-05 16:33:09 +0200655void qcow2_cache_clean_unused(Qcow2Cache *c);
Max Reitze7108fe2013-09-03 10:09:51 +0200656int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c);
657
Kevin Wolf49381092011-01-10 17:15:10 +0100658int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
659 void **table);
660int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
661 void **table);
Alberto Garcia2013c3d2018-02-05 16:33:07 +0200662void qcow2_cache_put(Qcow2Cache *c, void **table);
Alberto Garcia6e6fa762018-02-05 16:33:11 +0200663void *qcow2_cache_is_table_offset(Qcow2Cache *c, uint64_t offset);
Alberto Garcia77aadd72018-02-05 16:33:10 +0200664void qcow2_cache_discard(Qcow2Cache *c, void *table);
Kevin Wolf49381092011-01-10 17:15:10 +0100665
Vladimir Sementsov-Ogievskiy88ddffa2017-06-28 15:05:08 +0300666/* qcow2-bitmap.c functions */
667int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
668 void **refcount_table,
669 int64_t *refcount_table_size);
Vladimir Sementsov-Ogievskiy3e99da52018-02-02 19:07:52 +0300670bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp);
Vladimir Sementsov-Ogievskiyb1336cc2018-03-20 20:05:18 +0300671int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, bool *header_updated,
672 Error **errp);
Vladimir Sementsov-Ogievskiy1b6b0562017-06-28 15:05:14 +0300673int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp);
Vladimir Sementsov-Ogievskiy5f728262017-06-28 15:05:19 +0300674void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp);
Vladimir Sementsov-Ogievskiy169b8792017-06-28 15:05:20 +0300675int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp);
Vladimir Sementsov-Ogievskiyda0eb242017-06-28 15:05:22 +0300676bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs,
677 const char *name,
678 uint32_t granularity,
679 Error **errp);
Vladimir Sementsov-Ogievskiy469c71e2017-06-28 15:05:28 +0300680void qcow2_remove_persistent_dirty_bitmap(BlockDriverState *bs,
681 const char *name,
682 Error **errp);
Vladimir Sementsov-Ogievskiyd1258dd2017-06-28 15:05:11 +0300683
Kevin Wolff7d0fe02009-05-28 16:07:04 +0200684#endif