yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qemu-iotests-Test-BLOCK_JOB_READY-event-for-0Kb-imag.patch

9ae3a8
From 470f4cc7e63a96872463ab7a4a1c23689e32036b Mon Sep 17 00:00:00 2001
9ae3a8
From: Eric Blake <eblake@redhat.com>
9ae3a8
Date: Wed, 20 Aug 2014 16:40:11 +0200
9ae3a8
Subject: [PATCH 08/11] qemu-iotests: Test BLOCK_JOB_READY event for 0Kb image active commit
9ae3a8
9ae3a8
Message-id: <1408552814-23031-5-git-send-email-eblake@redhat.com>
9ae3a8
Patchwork-id: 60649
9ae3a8
O-Subject: [qemu-kvm-rhev 7.0.z PATCH 4/7] qemu-iotests: Test BLOCK_JOB_READY event for 0Kb image active commit
9ae3a8
Bugzilla: 1130603
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
9ae3a8
There should be a BLOCK_JOB_READY event with active commit, regardless
9ae3a8
of image length. Let's test the 0 length image case, and make sure it
9ae3a8
goes through the ready->complete process.
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 8b9a30ca5bc10545637429486836f3c206c39fab)
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	tests/qemu-iotests/040 - context, due to no common event infrastructure
9ae3a8
9ae3a8
Signed-off-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 tests/qemu-iotests/040     |   12 +++++++++---
9ae3a8
 tests/qemu-iotests/040.out |    4 ++--
9ae3a8
 2 files changed, 11 insertions(+), 5 deletions(-)
9ae3a8
9ae3a8
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
9ae3a8
index f210fb7..cf80e0c 100755
9ae3a8
--- a/tests/qemu-iotests/040
9ae3a8
+++ b/tests/qemu-iotests/040
9ae3a8
@@ -63,12 +63,13 @@ class ImageCommitTestCase(iotests.QMPTestCase):
9ae3a8
             i = i + 512
9ae3a8
         file.close()
9ae3a8
 
9ae3a8
-    def run_commit_test(self, top, base):
9ae3a8
+    def run_commit_test(self, top, base, need_ready=False):
9ae3a8
         self.assert_no_active_commit()
9ae3a8
         result = self.vm.qmp('block-commit', device='drive0', top=top, base=base)
9ae3a8
         self.assert_qmp(result, 'return', {})
9ae3a8
 
9ae3a8
         completed = False
9ae3a8
+        ready = False
9ae3a8
         while not completed:
9ae3a8
             for event in self.vm.get_qmp_events(wait=True):
9ae3a8
                 if event['event'] == 'BLOCK_JOB_COMPLETED':
9ae3a8
@@ -76,8 +77,11 @@ class ImageCommitTestCase(iotests.QMPTestCase):
9ae3a8
                     self.assert_qmp(event, 'data/device', 'drive0')
9ae3a8
                     self.assert_qmp(event, 'data/offset', self.image_len)
9ae3a8
                     self.assert_qmp(event, 'data/len', self.image_len)
9ae3a8
+                    if need_ready:
9ae3a8
+                        self.assertTrue(ready, "Expecting BLOCK_JOB_COMPLETED event")
9ae3a8
                     completed = True
9ae3a8
                 elif event['event'] == 'BLOCK_JOB_READY':
9ae3a8
+                    ready = True
9ae3a8
                     self.assert_qmp(event, 'data/type', 'commit')
9ae3a8
                     self.assert_qmp(event, 'data/device', 'drive0')
9ae3a8
                     self.assert_qmp(event, 'data/len', self.image_len)
9ae3a8
@@ -91,7 +95,7 @@ class TestSingleDrive(ImageCommitTestCase):
9ae3a8
     test_len = 1 * 1024 * 256
9ae3a8
 
9ae3a8
     def setUp(self):
9ae3a8
-        self.create_image(backing_img, TestSingleDrive.image_len)
9ae3a8
+        self.create_image(backing_img, self.image_len)
9ae3a8
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
9ae3a8
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
9ae3a8
         qemu_io('-c', 'write -P 0xab 0 524288', backing_img)
9ae3a8
@@ -133,7 +137,7 @@ class TestSingleDrive(ImageCommitTestCase):
9ae3a8
         self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
9ae3a8
 
9ae3a8
     def test_top_is_active(self):
9ae3a8
-        self.run_commit_test(test_img, backing_img)
9ae3a8
+        self.run_commit_test(test_img, backing_img, need_ready=True)
9ae3a8
         self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
9ae3a8
         self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
9ae3a8
 
9ae3a8
@@ -265,6 +269,8 @@ class TestSetSpeed(ImageCommitTestCase):
9ae3a8
 
9ae3a8
         self.cancel_and_wait()
9ae3a8
 
9ae3a8
+class TestActiveZeroLengthImage(TestSingleDrive):
9ae3a8
+    image_len = 0
9ae3a8
 
9ae3a8
 if __name__ == '__main__':
9ae3a8
     iotests.main(supported_fmts=['qcow2', 'qed'])
9ae3a8
diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out
9ae3a8
index b6f2576..42314e9 100644
9ae3a8
--- a/tests/qemu-iotests/040.out
9ae3a8
+++ b/tests/qemu-iotests/040.out
9ae3a8
@@ -1,5 +1,5 @@
9ae3a8
-................
9ae3a8
+........................
9ae3a8
 ----------------------------------------------------------------------
9ae3a8
-Ran 16 tests
9ae3a8
+Ran 24 tests
9ae3a8
 
9ae3a8
 OK
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8