KVM-test: Add a subtest 'qemu_img'

This is designed to test all subcommands of 'qemu-img' however
so far 'commit' is not implemented.

* For 'check' subcommand test, it will 'dd' to create a file with specified
size and see whether it's supported to be checked. Then convert it to be
supported formats ('qcow2' and 'raw' so far) to see whether there's error
after convertion.

* For 'convert' subcommand test, it will convert both to 'qcow2' and 'raw' from
the format specified in config file. And only check 'qcow2' after convertion.

* For 'snapshot' subcommand test, it will create two snapshots and list them.
Finally delete them if no errors found.

* For 'info' subcommand test, it will check image format & size according to
output of 'info' subcommand  at specified image file.

* For 'rebase' subcommand test, it will create first snapshot 'sn1' based on original
base_img, and create second snapshot based on sn1. And then rebase sn2 to base_img.
After rebase check the baking_file of sn2.

This supports two rebase mode: unsafe mode and safe mode:
Unsafe mode:
With -u an unsafe mode is enabled that doesn't require the backing files to exist.
It merely changes the backing file reference in the COW image. This is useful for
renaming or moving the backing file. The user is responsible to make sure that the
new backing file has no changes compared to the old one, or corruption may occur.

Safe Mode:
Both the current and the new backing file need to exist, and after the rebase, the
COW image is guaranteed to have the same guest visible content as before.
To achieve this, old and new backing file are compared and, if necessary, data is
copied from the old backing file into the COW image.

Improvement from v2:
 * Used utils functions instead of commands
 * Fixed some bugs on the check test
 * Put docstrings at some functions
 * Disable profiling during the test
 * Disable regular screenshots during the test

Signed-off-by: Yolkfull Chow <yzhou@redhat.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4414 592f7852-d20e-0410-864c-8624ca9c26a4
2 files changed