Commit Graph

278 Commits

Author SHA1 Message Date
Fam Zheng b59b3d5773 qemu-iotests: Make test case 030, 040 and 055 deterministic
Pause the drive and start the block job, so we won't miss the block job.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-29 13:40:37 +01:00
Fam Zheng 3cf53c7714 qemu-iotest: Add pause_drive and resume_drive methods
They wrap blkdebug "break" and "remove_break".

Add optional argument "resume" to cancel_and_wait().

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-29 13:40:37 +01:00
Fam Zheng 5b43dbb699 qemu-iotests: Drop local version of cancel_and_wait from 040
iotests.py already has one.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-29 13:40:37 +01:00
Max Reitz 171d64319c qemu-iotests: Fix test 041
Performing multiple drive-mirror blockjobs on the same qemu instance
results in the image file used for the block device being replaced by
the newly mirrored file, which is not what we want.

Fix this by performing one dedicated test per sync mode.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1385407736-13941-3-git-send-email-mreitz@redhat.com
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
2013-11-27 07:53:32 -08:00
Kevin Wolf 06d22aa367 block: Fail if requested driver is not available
If an explicit driver option is present, but doesn't specify a valid
driver, then bdrv_open() should fail instead of probing the format.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-15 13:37:48 +01:00
Fam Zheng 36452f12f8 qemu-img: Fix overwriting 'ret' before using
This patch moves ret assignment after reporting original error.

We were lucky to pass qemu-iotests 048 (qemu-img compare case) but when
I tried to run with TEST_DIR=/tmp (tmpfs), it fails with a "wrong"
mismatch offset. This fixes two bugs.

In the first if branch, setting ret to 1 before using it makes dead code
in the next line: pnum is never added to mismatch offset even if ret was
0.

In the other if branch, currently the output error is always -4:
  strerror(-4) -> Unknown error -4

Added regression test in case 048.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
2013-11-15 13:37:48 +01:00
Kevin Wolf a1144c0dbf qemu-iotests: Test qcow2 count_contiguous_clusters()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-15 13:37:43 +01:00
Max Reitz c15badee20 qemu-iotests: Extend 041 for unbacked mirroring
Add a new test case in file 041 for mirroring unbacked images in
"absolute-paths" mode. This should work, if possible, but most
importantly, qemu should never crash.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-11-14 13:09:06 +01:00
Fam Zheng b04b6b6ec3 block: Print its file name if backing file opening failed
If backing file doesn't exist, the error message is confusing and
misleading:

    $ qemu /tmp/a.qcow2
    qemu: could not open disk image /tmp/a.qcow2: Could not open file: No
    such file or directory

But...

    $ ls /tmp/a.qcow2
    /tmp/a.qcow2

    $ qemu-img info /tmp/a.qcow2
    image: /tmp/a.qcow2
    file format: qcow2
    virtual size: 8.0G (8589934592 bytes)
    disk size: 196K
    cluster_size: 65536
    backing file: /tmp/b.qcow2

Because...

    $ ls /tmp/b.qcow2
    ls: cannot access /tmp/b.qcow2: No such file or directory

This is not intuitive. It's better to have the missing file's name in
the error message. With this patch:

    $ qemu-io -c 'read 0 512' /tmp/a.qcow2
    qemu-io: can't open device /tmp/a.qcow2: Could not open backing
    file: Could not open '/stor/vm/arch.raw': No such file or directory
    no file open, try 'help open'

Which is a little bit better.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-11-14 13:09:06 +01:00
Jeff Cody e78835b722 block: vhdx qemu-iotest - log replay of data sector
This tests the replay of a data sector in a VHDX image file.

The image file is a 10G dynamic image, with 4MB block size.  The
image was created with qemu-img, and the log left unplayed by
modification of the vhdx image format driver.

It was verified under both QEMU and Hyper-V that the image file,
post log replay, matched.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:58:59 +01:00
Jeff Cody 751aec24cd block: qemu-iotests for vhdx, add write test support
This removes the IMGFMT_GENERIC blocker for read-only, so existing
iotests run read/write tests for vhdx images created by qemu-img (e.g.
tests 001, 002, 003).

In addition, this updates the sample image test for the Hyper-V
created image, to verify we can write it as well.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:58:59 +01:00
Jeff Cody 228b234dd7 block: vhdx - update _make_test_img() to filter out vhdx options
The non-global option output is suppresed in _make_test_img() for
output verification in the 0?? tests.  This adds suppression for
the vhdx-unique options as well.  This allows check -vhdx to run
successfully.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:58:59 +01:00
Jeff Cody db5dc55728 block: qemu-iotests, add quotes to $TEST_IMG usage in 061
When creating images with backing files in the test, the backing
file argument was not quoted properly.  This caused the test to fail
when run from a pathname with a space.  Pass the backing argument in
with the -b option to _make_test_img, so it can be properly quoted.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:31 +01:00
Jeff Cody 1ab391938d block: qemu-iotests, add quotes to $TEST_IMG usage for 051
There were still a couple of instances of unquoted usage of
$TEST_IMG and $TEST_IMG.orig.  Quoted these so they will not fail
on pathnames with spaces in them.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:31 +01:00
Jeff Cody f897e3939c block: qemu-iotests, removes duplicate double quotes in 039
Test 039 had $TEST_IMG with duplicate double quotes - remove duplicate.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:31 +01:00
Jeff Cody 3cbe3e8d25 block: qemu-iotests, add quotes to $TEST_IMG usage in 019
There were still instances of $TEST_IMG not being properly quoted.
This was in the usage of a string built up for a 'for' loop; modify
the loop so we can quote $TEST_IMG properly.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:31 +01:00
Jeff Cody 02cde16881 block: qemu-iotests, add quotes to $TEST_IMG.base usage in 017
$TEST_IMG.base is used unquoted. Add quotes so that pathnames with
spaces are supported.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:31 +01:00
Jeff Cody 0018c03f5d block: qemu-iotests, fix _make_test_img() to work with spaced pathnames
_make_test_img() currently works with spaced pathnames only when not
specifying a backing file.  This fixes it so that the backing file
argument is properly quoted.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:31 +01:00
Jeff Cody 0084043888 block: qemu-iotests, add quotes to $TEST_IMG usage io pattern tests
The usage of $TEST_IMG was not properly quoted everywhere in
common.pattern.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:31 +01:00
Max Reitz 64815e2a96 qemu-iotests: Filter out actual image size in 067
The actual size of the image file may differ depending on the Linux
kernel currently running on the host. Filtering out this value makes
this test pass in such cases.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-11-07 13:53:30 +01:00
Fam Zheng f4c129a38a vmdk: Implment bdrv_get_specific_info
Implement .bdrv_get_specific_info to return the extent information.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-31 14:44:43 +01:00
Fam Zheng 7890111b64 qemu-iotests: prefill some data to test image
Case 030 occasionally fails because of block job compltes too fast to be
captured by script, and 'unexpected qmp event' of job completion causes
the test failure.

Simply fill in some data to the test image to make this false alarm less
likely to happen.

(For other benefits to prefill data to test image, see also commit
ab68cdfaa).

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-30 12:51:45 +01:00
Max Reitz 321fd7d2b8 qemu-iotests: Test case for backing file deletion
Add a test case for trying to open an image file where it is impossible
to open its backing file (in this case, because it was deleted). When
doing this, qemu (or qemu-io in this case) should not crash but rather
print an appropriate error message.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-30 12:16:43 +01:00
Fam Zheng 915365a9c6 qemu-iotests: drop duplicated "create_image"
There's a same common function in iotests.py

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-30 11:58:46 +01:00
Kevin Wolf a7cf03d4e1 qemu-iotests: Fix 051 reference output
Commit 684b254 forgot to update it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-29 17:05:35 +01:00
Max Reitz ab6f2bbb28 qemu-iotests: Test for loading VM state from qcow2
Add a test for saving a VM state from a qcow2 image and loading it back
(with having restarted qemu in between); this should work without any
problems.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-25 11:08:20 +02:00
Max Reitz 34eeb82de6 qemu-iotests: Add test for inactive L2 overlap
Extend 060 by a test which creates a corrupted image with an active L2
entry pointing to an inactive L2 table and writes to the corresponding
guest offset.

Also, use overlap-check=all for all tests in 060.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:50:02 +02:00
Kevin Wolf a9b43397a9 qemu-iotests: Check autodel behaviour for device_del
Block devices creates with -drive and drive_add should automatically
disappear if the guest device is unplugged. blockdev-add ones shouldn't.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11 16:50:02 +02:00
Kevin Wolf 4f8a066b5f blockdev: Remove IF_* check for read-only blockdev_init
IF_NONE allows read-only, which makes forbidding it in this place
for other types pretty much pointless.

Instead, make sure that all devices for which the check would have
errored out check in their init function that they don't get a read-only
BlockDriverState. This catches even cases where IF_NONE and -device is
used.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2013-10-11 16:50:01 +02:00
Fam Zheng 52c8d629ca vmdk: refuse enabling zeroed grain with flat images
This is a header flag and we needs sparse for the header.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:50:01 +02:00
Fam Zheng 4823970bcb vmdk: convert error code to use errp
Convert "fprintf(stderr,..." and standardize error messages:

Remove a few local_error's and use errp.

Remove "VMDK:" or "Vmdk:" prefixes in error message and fix to upper
case.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:50:01 +02:00
Max Reitz e428e439df block/raw-posix: Employ error parameter
Make use of the error parameter in the opening and creating functions in
block/raw-posix.c.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:50:00 +02:00
Fam Zheng 5dd75f9afb qemu-iotests: move blank lines of output in case 059
Move the blank line to above the test step banner, so it looks clearer
in blocks.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:50:00 +02:00
Jeff Cody 89e911816a block: qemu-iotests for vhdx, read sample dynamic image
This adds the VHDX format to the qemu-iotests format, and adds
a read test.  The test reads from an existing sample image, that
was created with Hyper-V under Windwos Server 2012.

The image file is a 1GB dynamic image, with 32MB blocks.

The pattern 0xa5 exists from 0MB-33MB (past a block size boundary)

The pattern 0x96 exists from 33MB-66MB (past another block boundary,
and leaving a partial blank block)

From 66MB-1024MB, all reads should return 0.

Although 1GB dynamic image with 66MB of data, the bzip2'ed image
file size is only 874 bytes.

This also adds in the IMGFMT_GENERIC flag, so r/o images can be
tested (e.g. ./check -vhdx) without failing tests that assume
r/w support.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:49:59 +02:00
Max Reitz 975a93c082 qemu-iotests: Discard preallocated zero clusters
Add a new test case for discarding preallocated zero clusters; doing
this should not result in any leaks.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:49:59 +02:00
Max Reitz 3677e6f625 qemu-iotests: Additional info from qemu-img info
Add a test for the additional information now provided by qemu-img info
when used on qcow2 images. It also tests the qemu QMP output from the
query-block command when running qemu with different runtime options
than specified in the image (ImageInfoSpecific should always refer to
the image).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 16:49:50 +02:00
Max Reitz 4c2e946500 qemu-iotests: Discard specific info in _img_info
In _img_info, filter out additional information specific to the image
format provided by qemu-img info, since tests designed for multiple
image formats would produce different outputs for every image format
otherwise.

In a human-readable dump, that new information will always be last for
each "image information block" (multiple blocks are emitted when
inspecting the backing file chain). Every block is separated by an empty
line. Therefore, in this case, everything starting with the line "Format
specific information:" up to that empty line (or EOF, if it is the last
block) has to be stripped.

The JSON dump will always emit pretty JSON data. Therefore, the opening
and closing braces of every object will be on lines which are indented
by exactly the same amount, and all lines in between will have more
indentation. Thus, in this case, everything starting with a line
matching the regular expression /^ *"format-specific": {/ until /^ *},?/
has to be stripped, where the number of spaces at the beginning of the
respective lines is equal.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-10-11 14:04:58 +02:00
Anthony Liguori a107170537 Merge remote-tracking branch 'stefanha/block' into staging
# By Max Reitz (5) and others
# Via Stefan Hajnoczi
* stefanha/block:
  block: use correct filename
  qemu-iotests: Correct 026 output
  qcow2: Free allocated L2 cluster on error
  qcow2: Switch L1 table in a single sequence
  block: vhdx - add migration blocker
  block: use correct filename for error report
  qcow2: CHECK_OFLAG_COPIED is obsolete
  qcow2: Correct endianness in overlap check

Message-id: 1381145289-6591-1-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
2013-10-09 07:54:42 -07:00
Max Reitz 5c1fa87708 qemu-iotests: Correct 026 output
Because l2_allocate now frees the unused L2 cluster on error, the
according test cases in 026 don't result in one leaked cluster anymore.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-10-07 13:23:19 +02:00
Fam Zheng d1c295f572 .gitignore: ignore tests/qemu-iotests/socket_scm_helper
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Wenchao Xia<xiawenc@linux.vnet.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-10-01 16:06:07 +04:00
Max Reitz fd9e03e606 qemu-iotests: Preallocated zero clusters in 061
Add a test case for zero cluster expansion on an image completely filled
with preallocated zero clusters to test 061.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-27 11:16:36 +02:00
Jeff Cody fef9c19139 qemu-iotests: Quote $TEST_IMG* and $TEST_DIR usage
A lot of image filename and paths are used unquoted.  Quote these to
make sure that directories / filenames with spaces are not problematic.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-27 11:10:45 +02:00
Jeff Cody 85edbd375b qemu-iotests: Add basic ability to use binary sample images
For image formats that are not "QEMU native", but supported for
compatibility, it is useful to verify that an image created with
the 'gold standard' native tool can be read / written to successfully
by QEMU.

In addition to testing non-native images, this could also be useful to
test against image files created by older versions of QEMU.

This provides a directory to store small sample images, for use by
scripts in tests/qemu-iotests.

Image files should be compressed with bzip2.

To use a sample image from a bash script, the _use_sample_img function
will copy and decompress the image into $TEST_DIR, and set $TEST_IMG to
be the decompressed sample image copy.  To cleanup, call
_cleanup_test_img as normal.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-27 10:59:07 +02:00
Fam Zheng 212774c5a5 qemu-iotests: fix qmp.py search path
QMP/qmp.py is renamed to scripts/qmp/qmp.py, fix the search path in iotests.py.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-26 16:04:24 +02:00
Fam Zheng 2fe2e29071 qemu-iotests: add monolithicFlat creation test to 059
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-25 16:21:28 +02:00
Fam Zheng fc7ce63fb1 qemu-iotests: fix test case 059
Since commit "block: Error parameter for open functions", error output
is more verbose. Update test case output file to follow the change.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-25 16:21:28 +02:00
Max Reitz ff42308f30 qemu-iotests: Do not execute 052 with -nocache
Test 052 uses qemu-io -s which will result in bdrv_open trying to create
a temporary snapshot file in /tmp. However, since O_DIRECT and tmpfs
do not work well together, disable this test for -nocache.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-25 10:08:56 +02:00
Fam Zheng 4db9c98002 qemu-iotests: add test for backing file overriding
Test that backing.file.filename option can be parsed and override the
backing file from image (backing file reflected with "info block").

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-25 10:08:56 +02:00
Max Reitz c21bddf27f qemu-iotests: Fix test 038
Test 038 uses asynchronous I/O, resulting (potentially) in a different
output for every run (regarding the order of the I/O accesses). This can
be fixed by simply sorting the I/O access messages, since their order is
irrelevant anyway (for this asynchonous I/O).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-13 12:02:33 +02:00
Bharata B Rao 4aa846f25e qemu-iotests: Cleanup test image in test number 007
qemu-iotests number 007 doesn't do test image cleanup. This will affect
those protocols that expect a clean state before every test. Hence
ensure that test image is cleaned up in this test.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12 13:54:43 +02:00
Max Reitz 2c78857bf6 qemu-iotests: Adjustments due to error propagation
When opening/creating images, propagating errors instead of immediately
emitting them on occurrence results in errors generally being printed on
a single line rather than being split up into multiple ones. This in
turn requires adjustments to some test results.

Also, test 060 used a sed to filter out the test image directory and
format by removing everything from the affected line after a certain
keyword; this now also removes the error message itself, which can be
fixed by using _filter_testdir and _filter_imgfmt.

Finally, _make_test_img in common.rc did not filter out the test image
directory etc. from stderr. This has been fixed through a redirection of
stderr to stdout (which is already done in _check_test_img and
_img_info).

Signed-off-by: Max Reitz <mreitz@redhat.com>
2013-09-12 10:12:48 +02:00
Wenchao Xia 8023090be5 qemu-iotests: add 057 internal snapshot for block device test case
Create in transaction and deletion in single command will be tested.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12 10:12:47 +02:00
Max Reitz d982919d38 qemu-iotests: New test case in 061
Add one test case for zero cluster expansion on qcow2 version downgrade
in shared L2 tables (i.e., L2 tables with a refcount > 1) and one for
zero expansion on backed clusters in shared L2 tables.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12 10:12:47 +02:00
Wenchao Xia fd9c577b24 qemu-iotests: add tests for runtime fd passing via SCM rights
This case will test whether the monitor can receive fd at runtime.
To verify better, additional monitor is created to see if qemu
can handler two monitor instances correctly.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12 10:12:47 +02:00
Wenchao Xia 30b005d9d7 qemu-iotests: add infrastructure of fd passing via SCM
This patch make use of the compiled scm helper program to transfer
fd via unix socket at runtime.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12 10:12:46 +02:00
Wenchao Xia f93296eaff qemu-iotests: add unix socket help program
This program can do a sendmsg call to transfer fd with unix
socket, which is not supported in python2.

The built binary will not be deleted in clean, but it is a
existing issue in ./tests, which should be solved in another
patch.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12 10:12:46 +02:00
Max Reitz a8110c3d32 qemu-iotest: qcow2 image option amendment
Add tests for qemu-img amend on qcow2 image files.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-12 10:12:46 +02:00
Kevin Wolf 8f94b07787 qemu-iotests: Fixed test case 026
The reference output for test case 026 hasn't been updated in a long
time and it's one of the "known failing" cases. This patch updates the
reference output so that unintentional changes can be reliably detected
again.

The problem with this test case is that it produces different output
depending on whether -nocache is used or not. The solution of this patch
is to actually have two different reference outputs. If nnn.out.nocache
exists, it is used as the reference output for -nocache; otherwise,
nnn.out stays valid for both cases.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06 15:25:10 +02:00
Kevin Wolf 79e40ab10e qemu-iotests: Whitespace cleanup
These scripts used to have a four characters indentation, with eight
consecutive spaces converted into a tab. Convert everything into spaces.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06 15:25:09 +02:00
Alexandre Derumier b2e10493c7 add qemu-img convert -n option (skip target volume creation)
Add a -n option to skip volume creation on qemu-img convert.
This is useful for targets such as rbd / ceph, where the
target volume may already exist; we cannot always rely on
qemu-img convert to create the image, as dependent on the
output format, there may be parameters which are not possible
to specify through the qemu-img convert command line.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06 15:25:07 +02:00
Max Reitz b3f3a30f38 qemu-iotests: Adjust test result 039
The moved OFLAG_COPIED check in qcow2_check_refcounts results in a
different output from test 039 (mismatches are now found after the
general refcount check (as far as any remain)). This patch adjusts the
expected test result accordingly.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-09-06 15:25:07 +02:00
Max Reitz ca0eca91b6 qemu-iotests: Overlapping cluster allocations
A new test on corrupted images with overlapping cluster allocations.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-09-02 10:15:15 +02:00
Max Reitz 69c9872653 qcow2: Add corrupt bit
This adds an incompatible bit indicating corruption to qcow2. Any image
with this bit set may not be written to unless for repairing (and
subsequently clearing the bit if the repair has been successful).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-30 15:48:43 +02:00
Max Reitz 449df70638 qemu-iotests: Snapshotting zero clusters
This test creates an image with unallocated zero clusters, then creates
a snapshot. Afterwards, there should be neither any errors nor leaks.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-30 15:28:52 +02:00
Kevin Wolf cccc30b4ad qemu-iotests: Update reference output for 051
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-30 15:28:52 +02:00
Kevin Wolf c0447d870b Revert "block: Disable driver-specific options for 1.6"
This reverts commit 8afaefb891.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-30 15:28:52 +02:00
Fam Zheng 2c43e43c8c vmdk: check l1 size before opening image
L1 table size is calculated from capacity, granularity and l2 table
size. If capacity is too big or later two are too small, the L1 table
will be too big to allocate in memory. Limit it to a reasonable range.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-06 15:27:32 +02:00
Fam Zheng f8ce04036e vmdk: check l2 table size when opening
header.num_gtes_per_gte determines size for L2 table. Check for too big
value before using it. Limit to 512M entries (2GB per one L2 table).

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-06 15:27:32 +02:00
Fam Zheng 8aa1331c09 vmdk: check granularity field in opening
Granularity is used to calculate the cluster size and allocate r/w
buffer. Check the value from image before using it, so we don't abort()
for unbounded memory allocation.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-06 15:27:32 +02:00
Fam Zheng ca6cbb657d qemu-iotests: add empty test case for vmdk
Will add vmdk specific tests later here.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-06 15:27:32 +02:00
Stefan Hajnoczi 23ea2ecc2a qemu-iotests: add poke_file utility function
The new poke_file function sets bytes at an offset in a file given a
printf-style format string.  It can be used to corrupt an image file for
test coverage of error paths.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-06 15:27:32 +02:00
Stefan Hajnoczi 9580498b9a qemu-iotests: filter QEMU version in monitor banner
Filter out the QEMU monitor version banner so that tests do not break
when the QEMU version number is changed.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-08-06 10:41:56 +02:00
Kevin Wolf 8afaefb891 block: Disable driver-specific options for 1.6
We don't want to commit to the API yet before everything is worked out.
Like already for 1.5, disable it again for the 1.6 release. This commit
is meant to be reverted after the 1.6 release.

The disabling of the driver-specific options is achieved by applying the
old checks while parsing the command line.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-08-02 18:21:11 +02:00
Ian Main e3409362bd Add tests for sync modes 'TOP' and 'NONE'
This patch adds tests for sync modes top and none.  Test for 'TOP'
is separated out as it requires a backing file.  Also added a test
for invalid format.

Signed-off-by: Ian Main <imain@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-07-26 22:01:31 +02:00
Kevin Wolf 0f227a9470 blockdev: Rename 'readonly' option to 'read-only'
Option name cleanup before it becomes a QMP API.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2013-07-26 22:01:02 +02:00
Kevin Wolf 64aa99d3e0 qcow2: Use dashes instead of underscores in options
This is what QMP wants to use. The options haven't been enabled in any
release yet, so we're still free to change them.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2013-07-26 21:59:56 +02:00
Kevin Wolf 7a370406bd qemu-iotests: Update 051 reference output
This has been broken by commit bd5c51ee.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-07-15 09:49:00 +02:00
Kevin Wolf 98289620e0 block: Don't parse protocol from file.filename
One of the major reasons for doing something new for -blockdev and
blockdev-add was that the old block layer code parses filenames instead
of just taking them literally. So we should really leave it untouched
when it's passing using the new interfaces (like -drive
file.filename=...).

This allows opening relative file names that contain a colon.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2013-07-15 09:49:00 +02:00
Stefan Hajnoczi b53169eae0 blockdev: add sync mode to drive-backup QMP command
The drive-backup command is similar to the drive-mirror command, except
no guest data written after the command executes gets copied.  Add a
sync mode argument which determines whether the entire disk is copied,
just allocated clusters, or only clusters being written to by the guest.

Currently only sync mode 'full' is supported - it copies the entire disk.
For read-only point-in-time snapshots we may only need sync mode 'none'
since the target can be a qcow2 file using the guest's disk as its
backing file (no need to copy the entire disk).  Finally, sync mode
'top' is useful if we wish to preserve the backing chain.

Note that this patch just adds the sync mode argument to drive-backup.
It does not implement sync modes 'top' or 'none'.  This patch is
necessary so we can add a drive-backup HMP command that behaves like the
existing drive-mirror HMP command and takes a sync mode.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-07-15 09:49:00 +02:00
Stefan Hajnoczi e5ca8fdd40 qemu-iotests: add 055 drive-backup test case
Testing drive-backup is similar to image streaming and drive mirroring.
This test case is based on 041.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-06-28 09:20:27 +02:00
Stefan Hajnoczi 0dbe8a1b04 qemu-iotests: extract wait_until_completed() into iotests.py
The 'drive-mirror' tests often issue 'block-job-complete' and wait for
the QMP completion event.  Other types of block jobs also want to wait
for completion but they may not need to issue 'block-job-complete'.

Extract wait_until_completed() from 041 and put it into iotests.py.
Return the QMP event object so the caller can make additional
assertions, if necessary.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-06-28 09:20:27 +02:00
Kevin Wolf 492fdc6fbe Revert "block: Disable driver-specific options for 1.5"
This reverts commit 8ec7d390b0.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24 10:25:16 +02:00
Kevin Wolf 5e00984aef cutils: Support 'P' and 'E' suffixes in strtosz()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-06 11:27:03 +02:00
Stefan Hajnoczi 2499a096a2 qemu-iotests: make create_image() common
Both 030 and 041 use create_image().  Move it to iotests.py.

Also drop ImageStreamingTestCase since the class now has no methods.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-06-04 12:11:58 +02:00
Stefan Hajnoczi 3a3918c396 qemu-iotests: make compare_images() common
The iotests.compare_images() function returns True if two image files
have the identical data.  Previously this was implemented by converting
images to raw and then comparing their contents using Python.  Since
"qemu-img compare" is now available and is more efficient, switch to it.

This function will be reused by the 'drive-backup' test case.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-06-04 12:11:58 +02:00
Stefan Hajnoczi 2575fe16d2 qemu-iotests: make cancel_and_wait() common
The cancel_and_wait() function has been duplicated in 030 and 041.  Move
it into iotests.py and let it return the event so tests can perform
additional asserts.

Note that 041's cancel_and_wait(wait_ready=True) is replaced by
wait_ready_and_cancel(), which uses the new wait_ready() and
cancel_and_wait() underneath.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-06-04 12:11:58 +02:00
Stefan Hajnoczi ecc1c88efd qemu-iotests: make assert_no_active_block_jobs() common
Tests 030 and 041 both use query-block-jobs to check whether any block
jobs are active.  Make this code common so that 'drive-backup' and other
new feature tests will be able to reuse it.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-06-04 12:11:58 +02:00
Stefan Hajnoczi 8ddd08c5d1 qemu-iotests: fix 054 cluster size help output
Commit f3f4d2c09b added a hint to increase
the cluster size when a large image cannot be created.  Test 054 now has
outdated output and fails because the golden output does not match.

This patch updates the 054 golden output.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-06-04 12:11:57 +02:00
Stefan Hajnoczi 0412960617 tests: set MALLOC_PERTURB_ to expose memory bugs
glibc wipes malloc(3) memory when the MALLOC_PERTURB_ environment
variable is set.  The value of the environment variable determines the
bit pattern used to wipe memory.  For more information, see
http://udrepper.livejournal.com/11429.html.

Set MALLOC_PERTURB_ for gtester and qemu-iotests.  Note we pick a random
value from 1 to 255 to expose more bugs.  If you need to reproduce a
crash use 'show environment' in gdb to extract the MALLOC_PERTURB_
value from a core dump.

Both make check and qemu-iotests pass with MALLOC_PERTURB_ enabled.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1369661331-28041-1-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-05-29 08:16:06 -05:00
Kevin Wolf bd91ecbf5b qemu-iotests: Try creating huge qcow2 image
It's supposed to fail gracefully instead of segfaulting.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-05-24 16:17:55 +02:00
Kevin Wolf c93331c914 qcow2.py: Subcommand for changing header fields
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-05-24 16:17:55 +02:00
Fam Zheng 794d00f71d qemu-iotests: fix 017 018 for vmdk
017 and 018 use /bin/mv to move base img from t.IMGFMG to t.IMGFMT.base
after filling data, this is not enough for vmdk, when t.IMGFMT is only a
description text file who points to t-{flat,s001,f001,...}.IMGFMT as
data extent, so testing such subformats alway fails on them.

This patch use the trick of temprorily changing TEST_IMG to avoid using
/bin/mv.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-05-08 15:28:50 +02:00
Fam Zheng dbcdd7cb04 qemu-iotests: exclude vmdk and qcow from 043
043 tests recursive backing file by changing backing file. VMDK has not
implemented this yet, and qcow1 probably never will.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-05-08 15:28:49 +02:00
Fam Zheng 1afe272663 qemu-iotests: exclude vmdk for test 042
Zero sized disk is not supported by qemu vmdk driver, exclude vmdk from
the test script.

As tested on vmware-vdiskmanager and vmware workstation, zero sized disk
is not supported by vmware, either.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-05-08 15:28:49 +02:00
Fam Zheng 86abefd61e qemu-iotests: Filter out 'adapter_type'
Filter out vmdk creation option 'adapter_type' for vmdk. So that tests
with an explicit './check -o adapter_type=XXX' will not fail.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-05-03 13:06:22 +02:00
Fam Zheng 50522d969b qemu-iotests: Filter out vmdk creation options
Cover new image creation options for vmdk, so we can use '-o
zeroed_grain=XXX' and '-o subformat=XXX' to run the tests successfully.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-05-03 10:34:16 +02:00
Kevin Wolf 8ec7d390b0 block: Disable driver-specific options for 1.5
We don't want to commit to the API yet before everything is worked out.
Disable it for the 1.5 release. This commit is meant to be reverted
after the 1.5 release.

The disabling of the driver-specific options is achieved by applying the
old checks while parsing the command line.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-04-26 13:26:28 +02:00
Stefan Hajnoczi 7da94ca741 qemu-iotests: add 053 unaligned compressed image size test
Test that qemu-img convert -c works when input image length is not a
multiple of the cluster size.

Previously an error message would be produced:

  qemu-img: error while compressing sector 0: Input/output error

Now that qcow2 and qcow handle this case the test passes successfully.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-04-22 11:37:12 +02:00
Kevin Wolf 2af5ef70af block: Fail gracefully when using a format driver on protocol level
Specifying the wrong driver could fail an assertion:

$ qemu-system-x86_64 -drive file.driver=qcow2,file=x
qemu-system-x86_64: block.c:721: bdrv_open_common: Assertion `file !=
((void *)0)' failed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-04-22 10:27:59 +02:00
Kevin Wolf bdda92324d qemu-iotests: Fix _filter_qemu
$QEMU_PROG happens to be 'qemu' in my setup, so this sed command
replaces a bit too much. Restrict it to the start of the line and to
when it's followed by a colon, i.e. the form used by error messages.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-04-22 10:27:58 +02:00