2 * Block driver for Parallels disk image format
4 * Copyright (c) 2015-2017 Virtuozzo, Inc.
9 * This code was originally based on comparing different disk images created
10 * by Parallels. Currently it is based on opened OpenVZ sources
12 * https://github.com/OpenVZ/ploop
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this software and associated documentation files (the "Software"), to deal
16 * in the Software without restriction, including without limitation the rights
17 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 * copies of the Software, and to permit persons to whom the Software is
19 * furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32 #ifndef BLOCK_PARALLELS_H
33 #define BLOCK_PARALLELS_H
34 #include "qemu/coroutine.h"
36 #define HEADS_NUMBER 16
38 #define DEFAULT_CLUSTER_SIZE 1048576 /* 1 MiB */
40 /* always little-endian */
41 typedef struct ParallelsHeader {
42 char magic[16]; /* "WithoutFreeSpace" */
52 } QEMU_PACKED ParallelsHeader;
54 typedef enum ParallelsPreallocMode {
55 PRL_PREALLOC_MODE_FALLOCATE = 0,
56 PRL_PREALLOC_MODE_TRUNCATE = 1,
57 PRL_PREALLOC_MODE__MAX = 2,
58 } ParallelsPreallocMode;
60 typedef struct BDRVParallelsState {
61 /** Locking is conservative, the lock protects
62 * - image file extending (truncate, fallocate)
63 * - any access to block allocation table
67 ParallelsHeader *header;
71 unsigned long *bat_dirty_bmap;
72 unsigned int bat_dirty_block;
75 unsigned int bat_size;
78 uint64_t prealloc_size;
79 ParallelsPreallocMode prealloc_mode;
83 unsigned int off_multiplier;
84 Error *migration_blocker;