Skip to contentSkip to conversation

iotests: Test unaligned blocking mirror write

PATCH In review Max Reitz 2 participants 3 messages Aug 5, 2019

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 iotests: Test unaligned blocking mirror write

---
Hi, this is a test for the mirror bug Vladimir found. Naturally, it depends on some patch to fix it.

Based-on: <[email protected]>

---
 tests/qemu-iotests/151     | 25 +++++++++++++++++++++++++
 tests/qemu-iotests/151.out |  4 ++--
 2 files changed, 27 insertions(+), 2 deletions(-)
tests/qemu-iotests/151 +25 -0
index 1bb74d67c4..ad7359fc8d 100755
@@ -114,6 +114,31 @@ class TestActiveMirror(iotests.QMPTestCase):
     def testActiveIOFlushed(self):
         self.doActiveIO(True)
 
+    def testUnalignedActiveIO(self):
+        # Fill the source image
+        result = self.vm.hmp_qemu_io('source', 'write -P 1 0 2M')
+
+        # Start the block job (very slowly)
+        result = self.vm.qmp('blockdev-mirror',
+                             job_id='mirror',
+                             filter_node_name='mirror-node',
+                             device='source-node',
+                             target='target-node',
+                             sync='full',
+                             copy_mode='write-blocking',
+                             buf_size=(1048576 // 4),
+                             speed=1)
+        self.assert_qmp(result, 'return', {})
+
+        # Start an unaligned request to a dirty area
+        result = self.vm.hmp_qemu_io('source', 'write -P 2 %i 1' % (1048576 + 42))
+
+        # Let the job finish
+        result = self.vm.qmp('block-job-set-speed', device='mirror', speed=0)
+        self.assert_qmp(result, 'return', {})
+        self.complete_and_wait(drive='mirror')
+
+        self.potential_writes_in_flight = False
 
 
 if __name__ == '__main__':
tests/qemu-iotests/151.out +2 -2
index fbc63e62f8..8d7e996700 100644
@@ -1,5 +1,5 @@
-..
+...
 ----------------------------------------------------------------------
-Ran 2 tests
+Ran 3 tests
 
 OK
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Max Reitz

---
Hi, this is a test for the mirror bug Vladimir found. Naturally, it depends on some patch to fix it.

Based-on: <[email protected]>

---
  tests/qemu-iotests/151     | 25 +++++++++++++++++++++++++
  tests/qemu-iotests/151.out |  4 ++--
  2 files changed, 27 insertions(+), 2 deletions(-)
tests/qemu-iotests/151 +0 -0
index 1bb74d67c4..ad7359fc8d 100755

tests/qemu-iotests/151 class TestActiveMirror(iotests.QMPTestCase): · line 119

Quoted 6 lines
tests/qemu-iotests/151 +3 -0
@@ -114,6 +114,31 @@ class TestActiveMirror(iotests.QMPTestCase):
      def testActiveIOFlushed(self):
          self.doActiveIO(True)
 
+    def testUnalignedActiveIO(self):
+        # Fill the source image
+        result = self.vm.hmp_qemu_io('source', 'write -P 1 0 2M')

2M of ones

Quoted 5 lines
tests/qemu-iotests/151 +5 -0
+
+        # Start the block job (very slowly)
+        result = self.vm.qmp('blockdev-mirror',
+                             job_id='mirror',
+                             filter_node_name='mirror-node',

tests/qemu-iotests/151 class TestActiveMirror(iotests.QMPTestCase): · line 134

Quoted 10 lines
tests/qemu-iotests/151 +10 -0
+                             device='source-node',
+                             target='target-node',
+                             sync='full',
+                             copy_mode='write-blocking',
+                             buf_size=(1048576 // 4),
+                             speed=1)
+        self.assert_qmp(result, 'return', {})
+
+        # Start an unaligned request to a dirty area
+        result = self.vm.hmp_qemu_io('source', 'write -P 2 %i 1' % (1048576 + 42))

write only one byte, but unset the whole granularity chunk in bitmap, so it would be skipped from sequential mirroring loop, and final image comparison will fail

Quoted 16 lines
tests/qemu-iotests/151 +7 -0
+
+        # Let the job finish
+        result = self.vm.qmp('block-job-set-speed', device='mirror', speed=0)
+        self.assert_qmp(result, 'return', {})
+        self.complete_and_wait(drive='mirror')
+
+        self.potential_writes_in_flight = False
 
 
  if __name__ == '__main__':
tests/qemu-iotests/151.out +0 -0
index fbc63e62f8..8d7e996700 100644

tests/qemu-iotests/151.out line 5

Quoted 7 lines
tests/qemu-iotests/151.out +2 -2
@@ -1,5 +1,5 @@
-..
+...
  ----------------------------------------------------------------------
-Ran 2 tests
+Ran 3 tests
 
  OK

Not putting now tested-by as we didn't decide what is the base. However, I've checked that new test-case fails on master.

Signature · 2 lines
Best regards,
Vladimir
author
#2 lore raw
In reply to Max Reitz
Quoted 10 lines · Max Reitz

---
Hi, this is a test for the mirror bug Vladimir found. Naturally, it depends on some patch to fix it.

Based-on: <[email protected]>

---
 tests/qemu-iotests/151     | 25 +++++++++++++++++++++++++
 tests/qemu-iotests/151.out |  4 ++--
 2 files changed, 27 insertions(+), 2 deletions(-)

Thanks for the review, applied to my block branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block

Max