qemu-img: add the 'dd' subcommand

This patch adds a basic dd subcommand analogous to dd(1) to qemu-img.

For the start, this implements the bs, if, of and count options and requires
both if and of to be specified (no stdin/stdout if not specified) and doesn't
support tty, pipes, etc.

The image format must be specified with -O for the output if the raw format
is not the intended one.

Two tests are added to test qemu-img dd.

Signed-off-by: Reda Sallahi <fullmanet@gmail.com>
Message-id: 20160810024312.14544-1-fullmanet@gmail.com
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[mreitz: Moved test 158 to 170]
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Reda Sallahi 2016-08-10 04:43:12 +02:00 committed by Max Reitz
parent a008535b9f
commit 86ce1f6e2b
10 changed files with 584 additions and 5 deletions

View file

@ -139,6 +139,20 @@ Parameters to convert subcommand:
Skip the creation of the target volume
@end table
Parameters to dd subcommand:
@table @option
@item bs=@var{block_size}
defines the block size
@item count=@var{blocks}
sets the number of input blocks to copy
@item if=@var{input}
sets the input file
@item of=@var{output}
sets the output file
@end table
Command description:
@table @option
@ -310,6 +324,17 @@ skipped. This is useful for formats such as @code{rbd} if the target
volume has already been created with site specific options that cannot
be supplied through qemu-img.
@item dd [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] if=@var{input} of=@var{output}
Dd copies from @var{input} file to @var{output} file converting it from
@var{fmt} format to @var{output_fmt} format.
The data is by default read and written using blocks of 512 bytes but can be
modified by specifying @var{block_size}. If count=@var{blocks} is specified
dd will stop reading input after reading @var{blocks} input blocks.
The size syntax is similar to dd(1)'s size syntax.
@item info [-f @var{fmt}] [--output=@var{ofmt}] [--backing-chain] @var{filename}
Give information about the disk image @var{filename}. Use it in