diff mbox series

[v2,15/22] qemu-iotests/199: improve performance: set bitmap by discard

Message ID 20200217150246.29180-16-vsementsov@virtuozzo.com
State New
Headers show
Series Fix error handling during bitmap postcopy | expand

Commit Message

Vladimir Sementsov-Ogievskiy Feb. 17, 2020, 3:02 p.m. UTC
Discard dirties dirty-bitmap as well as write, but works faster. Let's
use it instead.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 tests/qemu-iotests/199 | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

Comments

Andrey Shinkevich Feb. 19, 2020, 2:17 p.m. UTC | #1
On 17/02/2020 18:02, Vladimir Sementsov-Ogievskiy wrote:
> Discard dirties dirty-bitmap as well as write, but works faster. Let's
> use it instead.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   tests/qemu-iotests/199 | 31 ++++++++++++++++++++-----------
>   1 file changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git a/tests/qemu-iotests/199 b/tests/qemu-iotests/199
> index 6599fc6fb4..d78f81b71c 100755
> --- a/tests/qemu-iotests/199
> +++ b/tests/qemu-iotests/199
> @@ -67,8 +67,10 @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
>           os.mkfifo(fifo)
>           qemu_img('create', '-f', iotests.imgfmt, disk_a, size)
>           qemu_img('create', '-f', iotests.imgfmt, disk_b, size)
> -        self.vm_a = iotests.VM(path_suffix='a').add_drive(disk_a)
> -        self.vm_b = iotests.VM(path_suffix='b').add_drive(disk_b)
> +        self.vm_a = iotests.VM(path_suffix='a').add_drive(disk_a,
> +                                                          'discard=unmap')
> +        self.vm_b = iotests.VM(path_suffix='b').add_drive(disk_b,
> +                                                          'discard=unmap')
>           self.vm_b.add_incoming("exec: cat '" + fifo + "'")
>           self.vm_a.launch()
>           self.vm_b.launch()
> @@ -78,7 +80,7 @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
>           self.vm_b_events = []
>   
>       def test_postcopy(self):
> -        write_size = 0x40000000
> +        discard_size = 0x40000000
>           granularity = 512
>           chunk = 4096
>   
> @@ -86,25 +88,32 @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
>                                  name='bitmap', granularity=granularity)
>           self.assert_qmp(result, 'return', {})
>   
> +        result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
> +                               node='drive0', name='bitmap')
> +        empty_sha256 = result['return']['sha256']
> +
>           s = 0
> -        while s < write_size:
> -            self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
> +        while s < discard_size:
> +            self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
>               s += 0x10000
>           s = 0x8000
> -        while s < write_size:
> -            self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
> +        while s < discard_size:
> +            self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
>               s += 0x10000
>   
>           result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
>                                  node='drive0', name='bitmap')
>           sha256 = result['return']['sha256']
>   
> +        # Check, that updating the bitmap by discards works
> +        assert sha256 != empty_sha256
> +
>           result = self.vm_a.qmp('block-dirty-bitmap-clear', node='drive0',
>                                  name='bitmap')
>           self.assert_qmp(result, 'return', {})
>           s = 0
> -        while s < write_size:
> -            self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
> +        while s < discard_size:
> +            self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
>               s += 0x10000
>   
>           caps = [{'capability': 'dirty-bitmaps', 'state': True},
> @@ -126,8 +135,8 @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
>           self.vm_b_events.append(e_resume)
>   
>           s = 0x8000
> -        while s < write_size:
> -            self.vm_b.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
> +        while s < discard_size:
> +            self.vm_b.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
>               s += 0x10000
>   
>           match = {'data': {'status': 'completed'}}
> 

Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
diff mbox series

Patch

diff --git a/tests/qemu-iotests/199 b/tests/qemu-iotests/199
index 6599fc6fb4..d78f81b71c 100755
--- a/tests/qemu-iotests/199
+++ b/tests/qemu-iotests/199
@@ -67,8 +67,10 @@  class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
         os.mkfifo(fifo)
         qemu_img('create', '-f', iotests.imgfmt, disk_a, size)
         qemu_img('create', '-f', iotests.imgfmt, disk_b, size)
-        self.vm_a = iotests.VM(path_suffix='a').add_drive(disk_a)
-        self.vm_b = iotests.VM(path_suffix='b').add_drive(disk_b)
+        self.vm_a = iotests.VM(path_suffix='a').add_drive(disk_a,
+                                                          'discard=unmap')
+        self.vm_b = iotests.VM(path_suffix='b').add_drive(disk_b,
+                                                          'discard=unmap')
         self.vm_b.add_incoming("exec: cat '" + fifo + "'")
         self.vm_a.launch()
         self.vm_b.launch()
@@ -78,7 +80,7 @@  class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
         self.vm_b_events = []
 
     def test_postcopy(self):
-        write_size = 0x40000000
+        discard_size = 0x40000000
         granularity = 512
         chunk = 4096
 
@@ -86,25 +88,32 @@  class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
                                name='bitmap', granularity=granularity)
         self.assert_qmp(result, 'return', {})
 
+        result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
+                               node='drive0', name='bitmap')
+        empty_sha256 = result['return']['sha256']
+
         s = 0
-        while s < write_size:
-            self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
+        while s < discard_size:
+            self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
             s += 0x10000
         s = 0x8000
-        while s < write_size:
-            self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
+        while s < discard_size:
+            self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
             s += 0x10000
 
         result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
                                node='drive0', name='bitmap')
         sha256 = result['return']['sha256']
 
+        # Check, that updating the bitmap by discards works
+        assert sha256 != empty_sha256
+
         result = self.vm_a.qmp('block-dirty-bitmap-clear', node='drive0',
                                name='bitmap')
         self.assert_qmp(result, 'return', {})
         s = 0
-        while s < write_size:
-            self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
+        while s < discard_size:
+            self.vm_a.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
             s += 0x10000
 
         caps = [{'capability': 'dirty-bitmaps', 'state': True},
@@ -126,8 +135,8 @@  class TestDirtyBitmapPostcopyMigration(iotests.QMPTestCase):
         self.vm_b_events.append(e_resume)
 
         s = 0x8000
-        while s < write_size:
-            self.vm_b.hmp_qemu_io('drive0', 'write %d %d' % (s, chunk))
+        while s < discard_size:
+            self.vm_b.hmp_qemu_io('drive0', 'discard %d %d' % (s, chunk))
             s += 0x10000
 
         match = {'data': {'status': 'completed'}}