bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Block driver for the COW format |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 3 | * |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 4 | * Copyright (c) 2004 Fabrice Bellard |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 5 | * |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 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 | */ |
pbrook | faf0796 | 2007-11-11 02:51:17 +0000 | [diff] [blame] | 24 | #include "qemu-common.h" |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 25 | #include "block_int.h" |
Anthony Liguori | 5efa9d5 | 2009-05-09 17:03:42 -0500 | [diff] [blame] | 26 | #include "module.h" |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 27 | |
| 28 | /**************************************************************/ |
| 29 | /* COW block driver using file system holes */ |
| 30 | |
| 31 | /* user mode linux compatible COW file */ |
| 32 | #define COW_MAGIC 0x4f4f4f4d /* MOOO */ |
| 33 | #define COW_VERSION 2 |
| 34 | |
| 35 | struct cow_header_v2 { |
| 36 | uint32_t magic; |
| 37 | uint32_t version; |
| 38 | char backing_file[1024]; |
| 39 | int32_t mtime; |
| 40 | uint64_t size; |
| 41 | uint32_t sectorsize; |
| 42 | }; |
| 43 | |
| 44 | typedef struct BDRVCowState { |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 45 | int64_t cow_sectors_offset; |
| 46 | } BDRVCowState; |
| 47 | |
| 48 | static int cow_probe(const uint8_t *buf, int buf_size, const char *filename) |
| 49 | { |
| 50 | const struct cow_header_v2 *cow_header = (const void *)buf; |
| 51 | |
bellard | 712e787 | 2005-04-28 21:09:32 +0000 | [diff] [blame] | 52 | if (buf_size >= sizeof(struct cow_header_v2) && |
| 53 | be32_to_cpu(cow_header->magic) == COW_MAGIC && |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 54 | be32_to_cpu(cow_header->version) == COW_VERSION) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 55 | return 100; |
| 56 | else |
| 57 | return 0; |
| 58 | } |
| 59 | |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 60 | static int cow_open(BlockDriverState *bs, int flags) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 61 | { |
| 62 | BDRVCowState *s = bs->opaque; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 63 | struct cow_header_v2 cow_header; |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 64 | int bitmap_size; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 65 | int64_t size; |
| 66 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 67 | /* see if it is a cow image */ |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 68 | if (bdrv_pread(bs->file, 0, &cow_header, sizeof(cow_header)) != |
| 69 | sizeof(cow_header)) { |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 70 | goto fail; |
| 71 | } |
| 72 | |
| 73 | if (be32_to_cpu(cow_header.magic) != COW_MAGIC || |
| 74 | be32_to_cpu(cow_header.version) != COW_VERSION) { |
| 75 | goto fail; |
| 76 | } |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 77 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 78 | /* cow image found */ |
| 79 | size = be64_to_cpu(cow_header.size); |
| 80 | bs->total_sectors = size / 512; |
| 81 | |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 82 | pstrcpy(bs->backing_file, sizeof(bs->backing_file), |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 83 | cow_header.backing_file); |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 84 | |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 85 | bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header); |
| 86 | s->cow_sectors_offset = (bitmap_size + 511) & ~511; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 87 | return 0; |
| 88 | fail: |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 89 | return -1; |
| 90 | } |
| 91 | |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 92 | /* |
| 93 | * XXX(hch): right now these functions are extremly ineffcient. |
| 94 | * We should just read the whole bitmap we'll need in one go instead. |
| 95 | */ |
| 96 | static inline int cow_set_bit(BlockDriverState *bs, int64_t bitnum) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 97 | { |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 98 | uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8; |
| 99 | uint8_t bitmap; |
| 100 | |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 101 | if (bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap)) != |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 102 | sizeof(bitmap)) { |
| 103 | return -errno; |
| 104 | } |
| 105 | |
| 106 | bitmap |= (1 << (bitnum % 8)); |
| 107 | |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 108 | if (bdrv_pwrite(bs->file, offset, &bitmap, sizeof(bitmap)) != |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 109 | sizeof(bitmap)) { |
| 110 | return -errno; |
| 111 | } |
| 112 | return 0; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 115 | static inline int is_bit_set(BlockDriverState *bs, int64_t bitnum) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 116 | { |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 117 | uint64_t offset = sizeof(struct cow_header_v2) + bitnum / 8; |
| 118 | uint8_t bitmap; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 119 | |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 120 | if (bdrv_pread(bs->file, offset, &bitmap, sizeof(bitmap)) != |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 121 | sizeof(bitmap)) { |
| 122 | return -errno; |
| 123 | } |
| 124 | |
| 125 | return !!(bitmap & (1 << (bitnum % 8))); |
| 126 | } |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 127 | |
| 128 | /* Return true if first block has been changed (ie. current version is |
| 129 | * in COW file). Set the number of continuous blocks for which that |
| 130 | * is true. */ |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 131 | static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num, |
| 132 | int nb_sectors, int *num_same) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 133 | { |
| 134 | int changed; |
| 135 | |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 136 | if (nb_sectors == 0) { |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 137 | *num_same = nb_sectors; |
| 138 | return 0; |
| 139 | } |
| 140 | |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 141 | changed = is_bit_set(bs, sector_num); |
| 142 | if (changed < 0) { |
| 143 | return 0; /* XXX: how to return I/O errors? */ |
| 144 | } |
| 145 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 146 | for (*num_same = 1; *num_same < nb_sectors; (*num_same)++) { |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 147 | if (is_bit_set(bs, sector_num + *num_same) != changed) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 148 | break; |
| 149 | } |
| 150 | |
| 151 | return changed; |
| 152 | } |
| 153 | |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 154 | static int cow_update_bitmap(BlockDriverState *bs, int64_t sector_num, |
| 155 | int nb_sectors) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 156 | { |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 157 | int error = 0; |
| 158 | int i; |
| 159 | |
| 160 | for (i = 0; i < nb_sectors; i++) { |
| 161 | error = cow_set_bit(bs, sector_num + i); |
| 162 | if (error) { |
| 163 | break; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | return error; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 168 | } |
| 169 | |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 170 | static int cow_read(BlockDriverState *bs, int64_t sector_num, |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 171 | uint8_t *buf, int nb_sectors) |
| 172 | { |
| 173 | BDRVCowState *s = bs->opaque; |
| 174 | int ret, n; |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 175 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 176 | while (nb_sectors > 0) { |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 177 | if (cow_is_allocated(bs, sector_num, nb_sectors, &n)) { |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 178 | ret = bdrv_pread(bs->file, |
| 179 | s->cow_sectors_offset + sector_num * 512, |
| 180 | buf, n * 512); |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 181 | if (ret != n * 512) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 182 | return -1; |
| 183 | } else { |
bellard | 83f6409 | 2006-08-01 16:21:11 +0000 | [diff] [blame] | 184 | if (bs->backing_hd) { |
| 185 | /* read from the base image */ |
| 186 | ret = bdrv_read(bs->backing_hd, sector_num, buf, n); |
| 187 | if (ret < 0) |
| 188 | return -1; |
| 189 | } else { |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 190 | memset(buf, 0, n * 512); |
| 191 | } |
bellard | 83f6409 | 2006-08-01 16:21:11 +0000 | [diff] [blame] | 192 | } |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 193 | nb_sectors -= n; |
| 194 | sector_num += n; |
| 195 | buf += n * 512; |
| 196 | } |
| 197 | return 0; |
| 198 | } |
| 199 | |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 200 | static int cow_write(BlockDriverState *bs, int64_t sector_num, |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 201 | const uint8_t *buf, int nb_sectors) |
| 202 | { |
| 203 | BDRVCowState *s = bs->opaque; |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 204 | int ret; |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 205 | |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 206 | ret = bdrv_pwrite(bs->file, s->cow_sectors_offset + sector_num * 512, |
| 207 | buf, nb_sectors * 512); |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 208 | if (ret != nb_sectors * 512) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 209 | return -1; |
Christoph Hellwig | 893a9cb | 2010-06-07 12:06:37 +0200 | [diff] [blame] | 210 | |
| 211 | return cow_update_bitmap(bs, sector_num, nb_sectors); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 212 | } |
| 213 | |
bellard | e2731ad | 2004-09-18 19:32:11 +0000 | [diff] [blame] | 214 | static void cow_close(BlockDriverState *bs) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 215 | { |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 216 | } |
| 217 | |
Kevin Wolf | 0e7e198 | 2009-05-18 16:42:10 +0200 | [diff] [blame] | 218 | static int cow_create(const char *filename, QEMUOptionParameter *options) |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 219 | { |
| 220 | int fd, cow_fd; |
| 221 | struct cow_header_v2 cow_header; |
| 222 | struct stat st; |
Kevin Wolf | 0e7e198 | 2009-05-18 16:42:10 +0200 | [diff] [blame] | 223 | int64_t image_sectors = 0; |
| 224 | const char *image_filename = NULL; |
Kirill A. Shutemov | 31f3812 | 2010-01-20 00:56:11 +0100 | [diff] [blame] | 225 | int ret; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 226 | |
Kevin Wolf | 0e7e198 | 2009-05-18 16:42:10 +0200 | [diff] [blame] | 227 | /* Read out options */ |
| 228 | while (options && options->name) { |
| 229 | if (!strcmp(options->name, BLOCK_OPT_SIZE)) { |
| 230 | image_sectors = options->value.n / 512; |
| 231 | } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { |
| 232 | image_filename = options->value.s; |
| 233 | } |
| 234 | options++; |
| 235 | } |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 236 | |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 237 | cow_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 238 | 0644); |
| 239 | if (cow_fd < 0) |
Juan Quintela | 48b66db | 2010-03-04 10:00:30 +0100 | [diff] [blame] | 240 | return -errno; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 241 | memset(&cow_header, 0, sizeof(cow_header)); |
| 242 | cow_header.magic = cpu_to_be32(COW_MAGIC); |
| 243 | cow_header.version = cpu_to_be32(COW_VERSION); |
| 244 | if (image_filename) { |
bellard | 83f6409 | 2006-08-01 16:21:11 +0000 | [diff] [blame] | 245 | /* Note: if no file, we put a dummy mtime */ |
| 246 | cow_header.mtime = cpu_to_be32(0); |
| 247 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 248 | fd = open(image_filename, O_RDONLY | O_BINARY); |
| 249 | if (fd < 0) { |
| 250 | close(cow_fd); |
bellard | 83f6409 | 2006-08-01 16:21:11 +0000 | [diff] [blame] | 251 | goto mtime_fail; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 252 | } |
| 253 | if (fstat(fd, &st) != 0) { |
| 254 | close(fd); |
bellard | 83f6409 | 2006-08-01 16:21:11 +0000 | [diff] [blame] | 255 | goto mtime_fail; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 256 | } |
| 257 | close(fd); |
| 258 | cow_header.mtime = cpu_to_be32(st.st_mtime); |
bellard | 83f6409 | 2006-08-01 16:21:11 +0000 | [diff] [blame] | 259 | mtime_fail: |
| 260 | pstrcpy(cow_header.backing_file, sizeof(cow_header.backing_file), |
| 261 | image_filename); |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 262 | } |
| 263 | cow_header.sectorsize = cpu_to_be32(512); |
| 264 | cow_header.size = cpu_to_be64(image_sectors * 512); |
Kirill A. Shutemov | 31f3812 | 2010-01-20 00:56:11 +0100 | [diff] [blame] | 265 | ret = qemu_write_full(cow_fd, &cow_header, sizeof(cow_header)); |
| 266 | if (ret != sizeof(cow_header)) { |
Juan Quintela | 48b66db | 2010-03-04 10:00:30 +0100 | [diff] [blame] | 267 | ret = -errno; |
Kirill A. Shutemov | 31f3812 | 2010-01-20 00:56:11 +0100 | [diff] [blame] | 268 | goto exit; |
| 269 | } |
| 270 | |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 271 | /* resize to include at least all the bitmap */ |
Kirill A. Shutemov | 31f3812 | 2010-01-20 00:56:11 +0100 | [diff] [blame] | 272 | ret = ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3)); |
| 273 | if (ret) { |
| 274 | ret = -errno; |
| 275 | goto exit; |
| 276 | } |
| 277 | |
Kirill A. Shutemov | 31f3812 | 2010-01-20 00:56:11 +0100 | [diff] [blame] | 278 | exit: |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 279 | close(cow_fd); |
Kirill A. Shutemov | 31f3812 | 2010-01-20 00:56:11 +0100 | [diff] [blame] | 280 | return ret; |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 281 | } |
| 282 | |
pbrook | 7a6cba6 | 2006-06-04 11:39:07 +0000 | [diff] [blame] | 283 | static void cow_flush(BlockDriverState *bs) |
| 284 | { |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 285 | bdrv_flush(bs->file); |
pbrook | 7a6cba6 | 2006-06-04 11:39:07 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Kevin Wolf | 0e7e198 | 2009-05-18 16:42:10 +0200 | [diff] [blame] | 288 | static QEMUOptionParameter cow_create_options[] = { |
Kevin Wolf | db08adf | 2009-06-04 15:39:38 +0200 | [diff] [blame] | 289 | { |
| 290 | .name = BLOCK_OPT_SIZE, |
| 291 | .type = OPT_SIZE, |
| 292 | .help = "Virtual disk size" |
| 293 | }, |
| 294 | { |
| 295 | .name = BLOCK_OPT_BACKING_FILE, |
| 296 | .type = OPT_STRING, |
| 297 | .help = "File name of a base image" |
| 298 | }, |
Kevin Wolf | 0e7e198 | 2009-05-18 16:42:10 +0200 | [diff] [blame] | 299 | { NULL } |
| 300 | }; |
| 301 | |
Anthony Liguori | 5efa9d5 | 2009-05-09 17:03:42 -0500 | [diff] [blame] | 302 | static BlockDriver bdrv_cow = { |
aurel32 | e60f469 | 2009-03-07 22:00:29 +0000 | [diff] [blame] | 303 | .format_name = "cow", |
| 304 | .instance_size = sizeof(BDRVCowState), |
| 305 | .bdrv_probe = cow_probe, |
Christoph Hellwig | 2063392 | 2010-06-07 12:06:47 +0200 | [diff] [blame^] | 306 | .bdrv_open = cow_open, |
aurel32 | e60f469 | 2009-03-07 22:00:29 +0000 | [diff] [blame] | 307 | .bdrv_read = cow_read, |
| 308 | .bdrv_write = cow_write, |
| 309 | .bdrv_close = cow_close, |
| 310 | .bdrv_create = cow_create, |
| 311 | .bdrv_flush = cow_flush, |
| 312 | .bdrv_is_allocated = cow_is_allocated, |
Kevin Wolf | 0e7e198 | 2009-05-18 16:42:10 +0200 | [diff] [blame] | 313 | |
| 314 | .create_options = cow_create_options, |
bellard | ea2384d | 2004-08-01 21:59:26 +0000 | [diff] [blame] | 315 | }; |
Anthony Liguori | 5efa9d5 | 2009-05-09 17:03:42 -0500 | [diff] [blame] | 316 | |
| 317 | static void bdrv_cow_init(void) |
| 318 | { |
| 319 | bdrv_register(&bdrv_cow); |
| 320 | } |
| 321 | |
| 322 | block_init(bdrv_cow_init); |