]> git.proxmox.com Git - mirror_qemu.git/blob - qemu-img.texi
qemu-img.texi: Clean up parameter list
[mirror_qemu.git] / qemu-img.texi
1 @example
2 @c man begin SYNOPSIS
3 @command{qemu-img} [@var{standard} @var{options}] @var{command} [@var{command} @var{options}]
4 @c man end
5 @end example
6
7 @c man begin DESCRIPTION
8 qemu-img allows you to create, convert and modify images offline. It can handle
9 all image formats supported by QEMU.
10
11 @b{Warning:} Never use qemu-img to modify images in use by a running virtual
12 machine or any other process; this may destroy the image. Also, be aware that
13 querying an image that is being modified by another process may encounter
14 inconsistent state.
15 @c man end
16
17 @c man begin OPTIONS
18
19 Standard options:
20 @table @option
21 @item -h, --help
22 Display this help and exit
23 @item -V, --version
24 Display version information and exit
25 @item -T, --trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
26 @findex --trace
27 @include qemu-option-trace.texi
28 @end table
29
30 The following commands are supported:
31
32 @include qemu-img-cmds.texi
33
34 Command parameters:
35 @table @var
36
37 @item filename
38 is a disk image filename
39
40 @item fmt
41 is the disk image format. It is guessed automatically in most cases. See below
42 for a description of the supported disk formats.
43
44 @item size
45 is the disk image size in bytes. Optional suffixes @code{k} or @code{K}
46 (kilobyte, 1024) @code{M} (megabyte, 1024k) and @code{G} (gigabyte, 1024M)
47 and T (terabyte, 1024G) are supported. @code{b} is ignored.
48
49 @item output_filename
50 is the destination disk image filename
51
52 @item output_fmt
53 is the destination format
54
55 @item options
56 is a comma separated list of format specific options in a
57 name=value format. Use @code{-o ?} for an overview of the options supported
58 by the used format or see the format descriptions below for details.
59
60 @item snapshot_param
61 is param used for internal snapshot, format is
62 'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]'
63
64 @item snapshot_id_or_name
65 is deprecated, use snapshot_param instead
66
67 @end table
68
69 @table @option
70
71 @item --object @var{objectdef}
72 is a QEMU user creatable object definition. See the @code{qemu(1)} manual
73 page for a description of the object properties. The most common object
74 type is a @code{secret}, which is used to supply passwords and/or encryption
75 keys.
76
77 @item --image-opts
78 Indicates that the source @var{filename} parameter is to be interpreted as a
79 full option string, not a plain filename. This parameter is mutually
80 exclusive with the @var{-f} parameter.
81
82 @item --target-image-opts
83 Indicates that the @var{output_filename} parameter(s) are to be interpreted as
84 a full option string, not a plain filename. This parameter is mutually
85 exclusive with the @var{-O} parameters. It is currently required to also use
86 the @var{-n} parameter to skip image creation. This restriction may be relaxed
87 in a future release.
88
89 @item --backing-chain
90 will enumerate information about backing files in a disk image chain. Refer
91 below for further description.
92
93 @item -c
94 indicates that target image must be compressed (qcow format only)
95
96 @item -h
97 with or without a command shows help and lists the supported formats
98
99 @item -p
100 display progress bar (compare, convert and rebase commands only).
101 If the @var{-p} option is not used for a command that supports it, the
102 progress is reported when the process receives a @code{SIGUSR1} or
103 @code{SIGINFO} signal.
104
105 @item -q
106 Quiet mode - do not print any output (except errors). There's no progress bar
107 in case both @var{-q} and @var{-p} options are used.
108
109 @item -S @var{size}
110 indicates the consecutive number of bytes that must contain only zeros
111 for qemu-img to create a sparse image during conversion. This value is rounded
112 down to the nearest 512 bytes. You may use the common size suffixes like
113 @code{k} for kilobytes.
114
115 @item -t @var{cache}
116 specifies the cache mode that should be used with the (destination) file. See
117 the documentation of the emulator's @code{-drive cache=...} option for allowed
118 values.
119
120 @item -T @var{src_cache}
121 specifies the cache mode that should be used with the source file(s). See
122 the documentation of the emulator's @code{-drive cache=...} option for allowed
123 values.
124
125 @end table
126
127 Parameters to snapshot subcommand:
128
129 @table @option
130
131 @item snapshot
132 is the name of the snapshot to create, apply or delete
133 @item -a
134 applies a snapshot (revert disk to saved state)
135 @item -c
136 creates a snapshot
137 @item -d
138 deletes a snapshot
139 @item -l
140 lists all snapshots in the given image
141 @end table
142
143 Parameters to compare subcommand:
144
145 @table @option
146
147 @item -f
148 First image format
149 @item -F
150 Second image format
151 @item -s
152 Strict mode - fail on different image size or sector allocation
153 @end table
154
155 Parameters to convert subcommand:
156
157 @table @option
158
159 @item -n
160 Skip the creation of the target volume
161 @item -m
162 Number of parallel coroutines for the convert process
163 @item -W
164 Allow out-of-order writes to the destination. This option improves performance,
165 but is only recommended for preallocated devices like host devices or other
166 raw block devices.
167 @end table
168
169 Parameters to dd subcommand:
170
171 @table @option
172
173 @item bs=@var{block_size}
174 defines the block size
175 @item count=@var{blocks}
176 sets the number of input blocks to copy
177 @item if=@var{input}
178 sets the input file
179 @item of=@var{output}
180 sets the output file
181 @item skip=@var{blocks}
182 sets the number of input blocks to skip
183 @end table
184
185 Command description:
186
187 @table @option
188 @item bench [-c @var{count}] [-d @var{depth}] [-f @var{fmt}] [--flush-interval=@var{flush_interval}] [-n] [--no-drain] [-o @var{offset}] [--pattern=@var{pattern}] [-q] [-s @var{buffer_size}] [-S @var{step_size}] [-t @var{cache}] [-w] @var{filename}
189
190 Run a simple sequential I/O benchmark on the specified image. If @code{-w} is
191 specified, a write test is performed, otherwise a read test is performed.
192
193 A total number of @var{count} I/O requests is performed, each @var{buffer_size}
194 bytes in size, and with @var{depth} requests in parallel. The first request
195 starts at the position given by @var{offset}, each following request increases
196 the current position by @var{step_size}. If @var{step_size} is not given,
197 @var{buffer_size} is used for its value.
198
199 If @var{flush_interval} is specified for a write test, the request queue is
200 drained and a flush is issued before new writes are made whenever the number of
201 remaining requests is a multiple of @var{flush_interval}. If additionally
202 @code{--no-drain} is specified, a flush is issued without draining the request
203 queue first.
204
205 If @code{-n} is specified, the native AIO backend is used if possible. On
206 Linux, this option only works if @code{-t none} or @code{-t directsync} is
207 specified as well.
208
209 For write tests, by default a buffer filled with zeros is written. This can be
210 overridden with a pattern byte specified by @var{pattern}.
211
212 @item check [-f @var{fmt}] [--output=@var{ofmt}] [-r [leaks | all]] [-T @var{src_cache}] @var{filename}
213
214 Perform a consistency check on the disk image @var{filename}. The command can
215 output in the format @var{ofmt} which is either @code{human} or @code{json}.
216
217 If @code{-r} is specified, qemu-img tries to repair any inconsistencies found
218 during the check. @code{-r leaks} repairs only cluster leaks, whereas
219 @code{-r all} fixes all kinds of errors, with a higher risk of choosing the
220 wrong fix or hiding corruption that has already occurred.
221
222 Only the formats @code{qcow2}, @code{qed} and @code{vdi} support
223 consistency checks.
224
225 In case the image does not have any inconsistencies, check exits with @code{0}.
226 Other exit codes indicate the kind of inconsistency found or if another error
227 occurred. The following table summarizes all exit codes of the check subcommand:
228
229 @table @option
230
231 @item 0
232 Check completed, the image is (now) consistent
233 @item 1
234 Check not completed because of internal errors
235 @item 2
236 Check completed, image is corrupted
237 @item 3
238 Check completed, image has leaked clusters, but is not corrupted
239 @item 63
240 Checks are not supported by the image format
241
242 @end table
243
244 If @code{-r} is specified, exit codes representing the image state refer to the
245 state after (the attempt at) repairing it. That is, a successful @code{-r all}
246 will yield the exit code 0, independently of the image state before.
247
248 @item create [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}]
249
250 Create the new disk image @var{filename} of size @var{size} and format
251 @var{fmt}. Depending on the file format, you can add one or more @var{options}
252 that enable additional features of this format.
253
254 If the option @var{backing_file} is specified, then the image will record
255 only the differences from @var{backing_file}. No size needs to be specified in
256 this case. @var{backing_file} will never be modified unless you use the
257 @code{commit} monitor command (or qemu-img commit).
258
259 If a relative path name is given, the backing file is looked up relative to
260 the directory containing @var{filename}.
261
262 Note that a given backing file will be opened to check that it is valid. Use
263 the @code{-u} option to enable unsafe backing file mode, which means that the
264 image will be created even if the associated backing file cannot be opened. A
265 matching backing file must be created or additional options be used to make the
266 backing file specification valid when you want to use an image created this
267 way.
268
269 The size can also be specified using the @var{size} option with @code{-o},
270 it doesn't need to be specified separately in this case.
271
272 @item commit [-q] [-f @var{fmt}] [-t @var{cache}] [-b @var{base}] [-d] [-p] @var{filename}
273
274 Commit the changes recorded in @var{filename} in its base image or backing file.
275 If the backing file is smaller than the snapshot, then the backing file will be
276 resized to be the same size as the snapshot. If the snapshot is smaller than
277 the backing file, the backing file will not be truncated. If you want the
278 backing file to match the size of the smaller snapshot, you can safely truncate
279 it yourself once the commit operation successfully completes.
280
281 The image @var{filename} is emptied after the operation has succeeded. If you do
282 not need @var{filename} afterwards and intend to drop it, you may skip emptying
283 @var{filename} by specifying the @code{-d} flag.
284
285 If the backing chain of the given image file @var{filename} has more than one
286 layer, the backing file into which the changes will be committed may be
287 specified as @var{base} (which has to be part of @var{filename}'s backing
288 chain). If @var{base} is not specified, the immediate backing file of the top
289 image (which is @var{filename}) will be used. Note that after a commit operation
290 all images between @var{base} and the top image will be invalid and may return
291 garbage data when read. For this reason, @code{-b} implies @code{-d} (so that
292 the top image stays valid).
293
294 @item compare [-f @var{fmt}] [-F @var{fmt}] [-T @var{src_cache}] [-p] [-s] [-q] @var{filename1} @var{filename2}
295
296 Check if two images have the same content. You can compare images with
297 different format or settings.
298
299 The format is probed unless you specify it by @var{-f} (used for
300 @var{filename1}) and/or @var{-F} (used for @var{filename2}) option.
301
302 By default, images with different size are considered identical if the larger
303 image contains only unallocated and/or zeroed sectors in the area after the end
304 of the other image. In addition, if any sector is not allocated in one image
305 and contains only zero bytes in the second one, it is evaluated as equal. You
306 can use Strict mode by specifying the @var{-s} option. When compare runs in
307 Strict mode, it fails in case image size differs or a sector is allocated in
308 one image and is not allocated in the second one.
309
310 By default, compare prints out a result message. This message displays
311 information that both images are same or the position of the first different
312 byte. In addition, result message can report different image size in case
313 Strict mode is used.
314
315 Compare exits with @code{0} in case the images are equal and with @code{1}
316 in case the images differ. Other exit codes mean an error occurred during
317 execution and standard error output should contain an error message.
318 The following table sumarizes all exit codes of the compare subcommand:
319
320 @table @option
321
322 @item 0
323 Images are identical
324 @item 1
325 Images differ
326 @item 2
327 Error on opening an image
328 @item 3
329 Error on checking a sector allocation
330 @item 4
331 Error on reading data
332
333 @end table
334
335 @item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-m @var{num_coroutines}] [-W] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
336
337 Convert the disk image @var{filename} or a snapshot @var{snapshot_param}(@var{snapshot_id_or_name} is deprecated)
338 to disk image @var{output_filename} using format @var{output_fmt}. It can be optionally compressed (@code{-c}
339 option) or use any format specific options like encryption (@code{-o} option).
340
341 Only the formats @code{qcow} and @code{qcow2} support compression. The
342 compression is read-only. It means that if a compressed sector is
343 rewritten, then it is rewritten as uncompressed data.
344
345 Image conversion is also useful to get smaller image when using a
346 growable format such as @code{qcow}: the empty sectors are detected and
347 suppressed from the destination image.
348
349 @var{sparse_size} indicates the consecutive number of bytes (defaults to 4k)
350 that must contain only zeros for qemu-img to create a sparse image during
351 conversion. If @var{sparse_size} is 0, the source will not be scanned for
352 unallocated or zero sectors, and the destination image will always be
353 fully allocated.
354
355 You can use the @var{backing_file} option to force the output image to be
356 created as a copy on write image of the specified base image; the
357 @var{backing_file} should have the same content as the input's base image,
358 however the path, image format, etc may differ.
359
360 If a relative path name is given, the backing file is looked up relative to
361 the directory containing @var{output_filename}.
362
363 If the @code{-n} option is specified, the target volume creation will be
364 skipped. This is useful for formats such as @code{rbd} if the target
365 volume has already been created with site specific options that cannot
366 be supplied through qemu-img.
367
368 Out of order writes can be enabled with @code{-W} to improve performance.
369 This is only recommended for preallocated devices like host devices or other
370 raw block devices. Out of order write does not work in combination with
371 creating compressed images.
372
373 @var{num_coroutines} specifies how many coroutines work in parallel during
374 the convert process (defaults to 8).
375
376 @item dd [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] [skip=@var{blocks}] if=@var{input} of=@var{output}
377
378 Dd copies from @var{input} file to @var{output} file converting it from
379 @var{fmt} format to @var{output_fmt} format.
380
381 The data is by default read and written using blocks of 512 bytes but can be
382 modified by specifying @var{block_size}. If count=@var{blocks} is specified
383 dd will stop reading input after reading @var{blocks} input blocks.
384
385 The size syntax is similar to dd(1)'s size syntax.
386
387 @item info [-f @var{fmt}] [--output=@var{ofmt}] [--backing-chain] @var{filename}
388
389 Give information about the disk image @var{filename}. Use it in
390 particular to know the size reserved on disk which can be different
391 from the displayed size. If VM snapshots are stored in the disk image,
392 they are displayed too. The command can output in the format @var{ofmt}
393 which is either @code{human} or @code{json}.
394
395 If a disk image has a backing file chain, information about each disk image in
396 the chain can be recursively enumerated by using the option @code{--backing-chain}.
397
398 For instance, if you have an image chain like:
399
400 @example
401 base.qcow2 <- snap1.qcow2 <- snap2.qcow2
402 @end example
403
404 To enumerate information about each disk image in the above chain, starting from top to base, do:
405
406 @example
407 qemu-img info --backing-chain snap2.qcow2
408 @end example
409
410 @item map [-f @var{fmt}] [--output=@var{ofmt}] @var{filename}
411
412 Dump the metadata of image @var{filename} and its backing file chain.
413 In particular, this commands dumps the allocation state of every sector
414 of @var{filename}, together with the topmost file that allocates it in
415 the backing file chain.
416
417 Two option formats are possible. The default format (@code{human})
418 only dumps known-nonzero areas of the file. Known-zero parts of the
419 file are omitted altogether, and likewise for parts that are not allocated
420 throughout the chain. @command{qemu-img} output will identify a file
421 from where the data can be read, and the offset in the file. Each line
422 will include four fields, the first three of which are hexadecimal
423 numbers. For example the first line of:
424 @example
425 Offset Length Mapped to File
426 0 0x20000 0x50000 /tmp/overlay.qcow2
427 0x100000 0x10000 0x95380000 /tmp/backing.qcow2
428 @end example
429 @noindent
430 means that 0x20000 (131072) bytes starting at offset 0 in the image are
431 available in /tmp/overlay.qcow2 (opened in @code{raw} format) starting
432 at offset 0x50000 (327680). Data that is compressed, encrypted, or
433 otherwise not available in raw format will cause an error if @code{human}
434 format is in use. Note that file names can include newlines, thus it is
435 not safe to parse this output format in scripts.
436
437 The alternative format @code{json} will return an array of dictionaries
438 in JSON format. It will include similar information in
439 the @code{start}, @code{length}, @code{offset} fields;
440 it will also include other more specific information:
441 @itemize @minus
442 @item
443 whether the sectors contain actual data or not (boolean field @code{data};
444 if false, the sectors are either unallocated or stored as optimized
445 all-zero clusters);
446
447 @item
448 whether the data is known to read as zero (boolean field @code{zero});
449
450 @item
451 in order to make the output shorter, the target file is expressed as
452 a @code{depth}; for example, a depth of 2 refers to the backing file
453 of the backing file of @var{filename}.
454 @end itemize
455
456 In JSON format, the @code{offset} field is optional; it is absent in
457 cases where @code{human} format would omit the entry or exit with an error.
458 If @code{data} is false and the @code{offset} field is present, the
459 corresponding sectors in the file are not yet in use, but they are
460 preallocated.
461
462 For more information, consult @file{include/block/block.h} in QEMU's
463 source code.
464
465 @item measure [--output=@var{ofmt}] [-O @var{output_fmt}] [-o @var{options}] [--size @var{N} | [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [-l @var{snapshot_param}] @var{filename}]
466
467 Calculate the file size required for a new image. This information can be used
468 to size logical volumes or SAN LUNs appropriately for the image that will be
469 placed in them. The values reported are guaranteed to be large enough to fit
470 the image. The command can output in the format @var{ofmt} which is either
471 @code{human} or @code{json}.
472
473 If the size @var{N} is given then act as if creating a new empty image file
474 using @command{qemu-img create}. If @var{filename} is given then act as if
475 converting an existing image file using @command{qemu-img convert}. The format
476 of the new file is given by @var{output_fmt} while the format of an existing
477 file is given by @var{fmt}.
478
479 A snapshot in an existing image can be specified using @var{snapshot_param}.
480
481 The following fields are reported:
482 @example
483 required size: 524288
484 fully allocated size: 1074069504
485 @end example
486
487 The @code{required size} is the file size of the new image. It may be smaller
488 than the virtual disk size if the image format supports compact representation.
489
490 The @code{fully allocated size} is the file size of the new image once data has
491 been written to all sectors. This is the maximum size that the image file can
492 occupy with the exception of internal snapshots, dirty bitmaps, vmstate data,
493 and other advanced image format features.
494
495 @item snapshot [-l | -a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot} ] @var{filename}
496
497 List, apply, create or delete snapshots in image @var{filename}.
498
499 @item rebase [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-p] [-u] -b @var{backing_file} [-F @var{backing_fmt}] @var{filename}
500
501 Changes the backing file of an image. Only the formats @code{qcow2} and
502 @code{qed} support changing the backing file.
503
504 The backing file is changed to @var{backing_file} and (if the image format of
505 @var{filename} supports this) the backing file format is changed to
506 @var{backing_fmt}. If @var{backing_file} is specified as ``'' (the empty
507 string), then the image is rebased onto no backing file (i.e. it will exist
508 independently of any backing file).
509
510 If a relative path name is given, the backing file is looked up relative to
511 the directory containing @var{filename}.
512
513 @var{cache} specifies the cache mode to be used for @var{filename}, whereas
514 @var{src_cache} specifies the cache mode for reading backing files.
515
516 There are two different modes in which @code{rebase} can operate:
517 @table @option
518 @item Safe mode
519 This is the default mode and performs a real rebase operation. The new backing
520 file may differ from the old one and qemu-img rebase will take care of keeping
521 the guest-visible content of @var{filename} unchanged.
522
523 In order to achieve this, any clusters that differ between @var{backing_file}
524 and the old backing file of @var{filename} are merged into @var{filename}
525 before actually changing the backing file.
526
527 Note that the safe mode is an expensive operation, comparable to converting
528 an image. It only works if the old backing file still exists.
529
530 @item Unsafe mode
531 qemu-img uses the unsafe mode if @code{-u} is specified. In this mode, only the
532 backing file name and format of @var{filename} is changed without any checks
533 on the file contents. The user must take care of specifying the correct new
534 backing file, or the guest-visible content of the image will be corrupted.
535
536 This mode is useful for renaming or moving the backing file to somewhere else.
537 It can be used without an accessible old backing file, i.e. you can use it to
538 fix an image whose backing file has already been moved/renamed.
539 @end table
540
541 You can use @code{rebase} to perform a ``diff'' operation on two
542 disk images. This can be useful when you have copied or cloned
543 a guest, and you want to get back to a thin image on top of a
544 template or base image.
545
546 Say that @code{base.img} has been cloned as @code{modified.img} by
547 copying it, and that the @code{modified.img} guest has run so there
548 are now some changes compared to @code{base.img}. To construct a thin
549 image called @code{diff.qcow2} that contains just the differences, do:
550
551 @example
552 qemu-img create -f qcow2 -b modified.img diff.qcow2
553 qemu-img rebase -b base.img diff.qcow2
554 @end example
555
556 At this point, @code{modified.img} can be discarded, since
557 @code{base.img + diff.qcow2} contains the same information.
558
559 @item resize [--shrink] [--preallocation=@var{prealloc}] @var{filename} [+ | -]@var{size}
560
561 Change the disk image as if it had been created with @var{size}.
562
563 Before using this command to shrink a disk image, you MUST use file system and
564 partitioning tools inside the VM to reduce allocated file systems and partition
565 sizes accordingly. Failure to do so will result in data loss!
566
567 When shrinking images, the @code{--shrink} option must be given. This informs
568 qemu-img that the user acknowledges all loss of data beyond the truncated
569 image's end.
570
571 After using this command to grow a disk image, you must use file system and
572 partitioning tools inside the VM to actually begin using the new space on the
573 device.
574
575 When growing an image, the @code{--preallocation} option may be used to specify
576 how the additional image area should be allocated on the host. See the format
577 description in the @code{NOTES} section which values are allowed. Using this
578 option may result in slightly more data being allocated than necessary.
579
580 @item amend [-p] [-f @var{fmt}] [-t @var{cache}] -o @var{options} @var{filename}
581
582 Amends the image format specific @var{options} for the image file
583 @var{filename}. Not all file formats support this operation.
584 @end table
585 @c man end
586
587 @ignore
588 @c man begin NOTES
589 Supported image file formats:
590
591 @table @option
592 @item raw
593
594 Raw disk image format (default). This format has the advantage of
595 being simple and easily exportable to all other emulators. If your
596 file system supports @emph{holes} (for example in ext2 or ext3 on
597 Linux or NTFS on Windows), then only the written sectors will reserve
598 space. Use @code{qemu-img info} to know the real size used by the
599 image or @code{ls -ls} on Unix/Linux.
600
601 Supported options:
602 @table @code
603 @item preallocation
604 Preallocation mode (allowed values: @code{off}, @code{falloc}, @code{full}).
605 @code{falloc} mode preallocates space for image by calling posix_fallocate().
606 @code{full} mode preallocates space for image by writing zeros to underlying
607 storage.
608 @end table
609
610 @item qcow2
611 QEMU image format, the most versatile format. Use it to have smaller
612 images (useful if your filesystem does not supports holes, for example
613 on Windows), optional AES encryption, zlib based compression and
614 support of multiple VM snapshots.
615
616 Supported options:
617 @table @code
618 @item compat
619 Determines the qcow2 version to use. @code{compat=0.10} uses the
620 traditional image format that can be read by any QEMU since 0.10.
621 @code{compat=1.1} enables image format extensions that only QEMU 1.1 and
622 newer understand (this is the default). Amongst others, this includes zero
623 clusters, which allow efficient copy-on-read for sparse images.
624
625 @item backing_file
626 File name of a base image (see @option{create} subcommand)
627 @item backing_fmt
628 Image format of the base image
629 @item encryption
630 If this option is set to @code{on}, the image is encrypted with 128-bit AES-CBC.
631
632 The use of encryption in qcow and qcow2 images is considered to be flawed by
633 modern cryptography standards, suffering from a number of design problems:
634
635 @itemize @minus
636 @item
637 The AES-CBC cipher is used with predictable initialization vectors based
638 on the sector number. This makes it vulnerable to chosen plaintext attacks
639 which can reveal the existence of encrypted data.
640 @item
641 The user passphrase is directly used as the encryption key. A poorly
642 chosen or short passphrase will compromise the security of the encryption.
643 @item
644 In the event of the passphrase being compromised there is no way to
645 change the passphrase to protect data in any qcow images. The files must
646 be cloned, using a different encryption passphrase in the new file. The
647 original file must then be securely erased using a program like shred,
648 though even this is ineffective with many modern storage technologies.
649 @item
650 Initialization vectors used to encrypt sectors are based on the
651 guest virtual sector number, instead of the host physical sector. When
652 a disk image has multiple internal snapshots this means that data in
653 multiple physical sectors is encrypted with the same initialization
654 vector. With the CBC mode, this opens the possibility of watermarking
655 attacks if the attack can collect multiple sectors encrypted with the
656 same IV and some predictable data. Having multiple qcow2 images with
657 the same passphrase also exposes this weakness since the passphrase
658 is directly used as the key.
659 @end itemize
660
661 Use of qcow / qcow2 encryption is thus strongly discouraged. Users are
662 recommended to use an alternative encryption technology such as the
663 Linux dm-crypt / LUKS system.
664
665 @item cluster_size
666 Changes the qcow2 cluster size (must be between 512 and 2M). Smaller cluster
667 sizes can improve the image file size whereas larger cluster sizes generally
668 provide better performance.
669
670 @item preallocation
671 Preallocation mode (allowed values: @code{off}, @code{metadata}, @code{falloc},
672 @code{full}). An image with preallocated metadata is initially larger but can
673 improve performance when the image needs to grow. @code{falloc} and @code{full}
674 preallocations are like the same options of @code{raw} format, but sets up
675 metadata also.
676
677 @item lazy_refcounts
678 If this option is set to @code{on}, reference count updates are postponed with
679 the goal of avoiding metadata I/O and improving performance. This is
680 particularly interesting with @option{cache=writethrough} which doesn't batch
681 metadata updates. The tradeoff is that after a host crash, the reference count
682 tables must be rebuilt, i.e. on the next open an (automatic) @code{qemu-img
683 check -r all} is required, which may take some time.
684
685 This option can only be enabled if @code{compat=1.1} is specified.
686
687 @item nocow
688 If this option is set to @code{on}, it will turn off COW of the file. It's only
689 valid on btrfs, no effect on other file systems.
690
691 Btrfs has low performance when hosting a VM image file, even more when the guest
692 on the VM also using btrfs as file system. Turning off COW is a way to mitigate
693 this bad performance. Generally there are two ways to turn off COW on btrfs:
694 a) Disable it by mounting with nodatacow, then all newly created files will be
695 NOCOW. b) For an empty file, add the NOCOW file attribute. That's what this option
696 does.
697
698 Note: this option is only valid to new or empty files. If there is an existing
699 file which is COW and has data blocks already, it couldn't be changed to NOCOW
700 by setting @code{nocow=on}. One can issue @code{lsattr filename} to check if
701 the NOCOW flag is set or not (Capital 'C' is NOCOW flag).
702
703 @end table
704
705 @item Other
706 QEMU also supports various other image file formats for compatibility with
707 older QEMU versions or other hypervisors, including VMDK, VDI, VHD (vpc), VHDX,
708 qcow1 and QED. For a full list of supported formats see @code{qemu-img --help}.
709 For a more detailed description of these formats, see the QEMU Emulation User
710 Documentation.
711
712 The main purpose of the block drivers for these formats is image conversion.
713 For running VMs, it is recommended to convert the disk images to either raw or
714 qcow2 in order to achieve good performance.
715 @end table
716
717
718 @c man end
719
720 @setfilename qemu-img
721 @settitle QEMU disk image utility
722
723 @c man begin SEEALSO
724 The HTML documentation of QEMU for more precise information and Linux
725 user mode emulator invocation.
726 @c man end
727
728 @c man begin AUTHOR
729 Fabrice Bellard
730 @c man end
731
732 @end ignore