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

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