summaryrefslogtreecommitdiffstats
path: root/tests/qemu-iotests/041
diff options
context:
space:
mode:
authorVishvananda Ishaya2013-01-25 19:57:20 +0100
committerStefan Hajnoczi2013-02-01 14:58:28 +0100
commita04eca108e5efe8a09fe82f7079fcd1568ffc8d7 (patch)
treee5ee3bf71e85a0bf68f422ecd6206eaf2a1b6b67 /tests/qemu-iotests/041
parentblock: Fix is_allocated_above with resized files (diff)
downloadqemu-a04eca108e5efe8a09fe82f7079fcd1568ffc8d7.tar.gz
qemu-a04eca108e5efe8a09fe82f7079fcd1568ffc8d7.tar.xz
qemu-a04eca108e5efe8a09fe82f7079fcd1568ffc8d7.zip
block: Adds mirroring tests for resized images
This test verifies two mirroring issues are fixed with resized images: * sync='top' creates an image that is the proper size * sync='full' doesn't cause an assertion failure and crash qemu Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/041')
-rwxr-xr-xtests/qemu-iotests/04148
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index b040820c51..720eeff921 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -344,6 +344,54 @@ class TestMirrorNoBacking(ImageMirroringTestCase):
self.assertTrue(self.compare_images(test_img, target_img),
'target image does not match source after mirroring')
+class TestMirrorResized(ImageMirroringTestCase):
+ backing_len = 1 * 1024 * 1024 # MB
+ image_len = 2 * 1024 * 1024 # MB
+
+ def setUp(self):
+ self.create_image(backing_img, TestMirrorResized.backing_len)
+ qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
+ qemu_img('resize', test_img, '2M')
+ self.vm = iotests.VM().add_drive(test_img)
+ self.vm.launch()
+
+ def tearDown(self):
+ self.vm.shutdown()
+ os.remove(test_img)
+ os.remove(backing_img)
+ try:
+ os.remove(target_img)
+ except OSError:
+ pass
+
+ def test_complete_top(self):
+ self.assert_no_active_mirrors()
+
+ result = self.vm.qmp('drive-mirror', device='drive0', sync='top',
+ target=target_img)
+ self.assert_qmp(result, 'return', {})
+
+ self.complete_and_wait()
+ result = self.vm.qmp('query-block')
+ self.assert_qmp(result, 'return[0]/inserted/file', target_img)
+ self.vm.shutdown()
+ self.assertTrue(self.compare_images(test_img, target_img),
+ 'target image does not match source after mirroring')
+
+ def test_complete_full(self):
+ self.assert_no_active_mirrors()
+
+ result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
+ target=target_img)
+ self.assert_qmp(result, 'return', {})
+
+ self.complete_and_wait()
+ result = self.vm.qmp('query-block')
+ self.assert_qmp(result, 'return[0]/inserted/file', target_img)
+ self.vm.shutdown()
+ self.assertTrue(self.compare_images(test_img, target_img),
+ 'target image does not match source after mirroring')
+
class TestReadErrors(ImageMirroringTestCase):
image_len = 2 * 1024 * 1024 # MB