- * [PATCH 01/10] iotests: Create VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 02/10] iotests: 255: Drop blockdev_create() Kevin Wolf
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
We have several almost identical copies of a blockdev_create() function
in different test cases. Time to create one unified function in
iotests.py.
To keep the diff managable, this patch only creates the function and
follow-up patches will convert the individual test cases.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/iotests.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index b46d298766..8739ec6613 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -643,6 +643,22 @@ class VM(qtest.QEMUQtestMachine):
             elif status == 'null':
                 return error
 
+    # Returns None on success, and an error string on failure
+    def blockdev_create(self, options, job_id='job0', filters=None):
+        if filters is None:
+            filters = [filter_qmp_testfiles]
+        result = self.qmp_log('blockdev-create', filters=filters,
+                              job_id=job_id, options=options)
+
+        if 'return' in result:
+            assert result['return'] == {}
+            job_result = self.run_job(job_id)
+        else:
+            job_result = result['error']
+
+        log("")
+        return job_result
+
     def enable_migration_events(self, name):
         log('Enabling migration QMP events on %s...' % name)
         log(self.qmp('migrate-set-capabilities', capabilities=[
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 02/10] iotests: 255: Drop blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
  2019-12-16 17:08 ` [PATCH 01/10] iotests: Create VM.blockdev_create() Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 03/10] iotests: 206: Convert to VM.blockdev_create() Kevin Wolf
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
blockdev_create() is completely unused in this test case, so we can just
drop it.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/255 | 10 ----------
 1 file changed, 10 deletions(-)
diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255
index 3632d507d0..0ba03d9e61 100755
--- a/tests/qemu-iotests/255
+++ b/tests/qemu-iotests/255
@@ -25,16 +25,6 @@ from iotests import imgfmt
 
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
-def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create',
-                        filters=[iotests.filter_qmp_testfiles],
-                        job_id='job0', options=options)
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-    iotests.log("")
-
 iotests.log('Finishing a commit job with background reads')
 iotests.log('============================================')
 iotests.log('')
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 03/10] iotests: 206: Convert to VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
  2019-12-16 17:08 ` [PATCH 01/10] iotests: Create VM.blockdev_create() Kevin Wolf
  2019-12-16 17:08 ` [PATCH 02/10] iotests: 255: Drop blockdev_create() Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 04/10] iotests: 210: " Kevin Wolf
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
Instead of having a separate blockdev_create() function, make use of the
VM.blockdev_create() offered by iotests.py.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/206 | 232 ++++++++++++++++++++---------------------
 1 file changed, 111 insertions(+), 121 deletions(-)
diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206
index 5bb738bf23..9f16a7df8d 100755
--- a/tests/qemu-iotests/206
+++ b/tests/qemu-iotests/206
@@ -25,16 +25,6 @@ from iotests import imgfmt
 
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
-def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create',
-                        filters=[iotests.filter_qmp_testfiles],
-                        job_id='job0', options=options)
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-    iotests.log("")
-
 with iotests.FilePath('t.qcow2') as disk_path, \
      iotests.FilePath('t.qcow2.base') as backing_path, \
      iotests.VM() as vm:
@@ -50,18 +40,18 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     size = 128 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
 
     vm.qmp_log('blockdev-add',
                filters=[iotests.filter_qmp_testfiles],
                driver='file', filename=disk_path,
                node_name='imgfile')
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'imgfile',
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'imgfile',
+                         'size': size })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -76,23 +66,23 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     size = 64 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0,
-                          'preallocation': 'off',
-                          'nocow': False })
-
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'version': 'v3',
-                          'cluster-size': 65536,
-                          'preallocation': 'off',
-                          'lazy-refcounts': False,
-                          'refcount-bits': 16 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0,
+                         'preallocation': 'off',
+                         'nocow': False })
+
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'version': 'v3',
+                         'cluster-size': 65536,
+                         'preallocation': 'off',
+                         'lazy-refcounts': False,
+                         'refcount-bits': 16 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -107,23 +97,23 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     size = 32 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0,
-                          'preallocation': 'falloc',
-                          'nocow': True })
-
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'version': 'v3',
-                          'cluster-size': 2097152,
-                          'preallocation': 'metadata',
-                          'lazy-refcounts': True,
-                          'refcount-bits': 1 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0,
+                         'preallocation': 'falloc',
+                         'nocow': True })
+
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'version': 'v3',
+                         'cluster-size': 2097152,
+                         'preallocation': 'metadata',
+                         'lazy-refcounts': True,
+                         'refcount-bits': 1 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -135,20 +125,20 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'backing-file': backing_path,
-                          'backing-fmt': 'qcow2',
-                          'version': 'v2',
-                          'cluster-size': 512 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'backing-file': backing_path,
+                         'backing-fmt': 'qcow2',
+                         'version': 'v2',
+                         'cluster-size': 512 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -160,22 +150,22 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'encrypt': {
-                              'format': 'luks',
-                              'key-secret': 'keysec0',
-                              'cipher-alg': 'twofish-128',
-                              'cipher-mode': 'ctr',
-                              'ivgen-alg': 'plain64',
-                              'ivgen-hash-alg': 'md5',
-                              'hash-alg': 'sha1',
-                              'iter-time': 10,
-                          }})
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'encrypt': {
+                             'format': 'luks',
+                             'key-secret': 'keysec0',
+                             'cipher-alg': 'twofish-128',
+                             'cipher-mode': 'ctr',
+                             'ivgen-alg': 'plain64',
+                             'ivgen-hash-alg': 'md5',
+                             'hash-alg': 'sha1',
+                             'iter-time': 10,
+                         }})
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -187,9 +177,9 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': "this doesn't exist",
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': "this doesn't exist",
+                         'size': size })
     vm.shutdown()
 
     #
@@ -211,9 +201,9 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     vm.launch()
     for size in [ 1234, 18446744073709551104, 9223372036854775808,
                   9223372036854775296 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': size })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': size })
     vm.shutdown()
 
     #
@@ -222,20 +212,20 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     iotests.log("=== Invalid version ===")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 67108864,
-                          'version': 'v1' })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 67108864,
-                          'version': 'v2',
-                          'lazy-refcounts': True })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 67108864,
-                          'version': 'v2',
-                          'refcount-bits': 8 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 67108864,
+                         'version': 'v1' })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 67108864,
+                         'version': 'v2',
+                         'lazy-refcounts': True })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 67108864,
+                         'version': 'v2',
+                         'refcount-bits': 8 })
     vm.shutdown()
 
     #
@@ -244,15 +234,15 @@ with iotests.FilePath('t.qcow2') as disk_path, \
     iotests.log("=== Invalid backing file options ===")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 67108864,
-                          'backing-file': '/dev/null',
-                          'preallocation': 'full' })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 67108864,
-                          'backing-fmt': imgfmt })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 67108864,
+                         'backing-file': '/dev/null',
+                         'preallocation': 'full' })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 67108864,
+                         'backing-fmt': imgfmt })
     vm.shutdown()
 
     #
@@ -262,14 +252,14 @@ with iotests.FilePath('t.qcow2') as disk_path, \
 
     vm.launch()
     for csize in [ 1234, 128, 4194304, 0 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': 67108864,
-                              'cluster-size': csize })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 281474976710656,
-                          'cluster-size': 512 })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': 67108864,
+                             'cluster-size': csize })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 281474976710656,
+                         'cluster-size': 512 })
     vm.shutdown()
 
     #
@@ -279,8 +269,8 @@ with iotests.FilePath('t.qcow2') as disk_path, \
 
     vm.launch()
     for refcount_bits in [ 128, 0, 7 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': 67108864,
-                              'refcount-bits': refcount_bits })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': 67108864,
+                             'refcount-bits': refcount_bits })
     vm.shutdown()
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 04/10] iotests: 210: Convert to VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
                   ` (2 preceding siblings ...)
  2019-12-16 17:08 ` [PATCH 03/10] iotests: 206: Convert to VM.blockdev_create() Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 05/10] iotests: 212: " Kevin Wolf
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
Instead of having a separate blockdev_create() function, make use of the
VM.blockdev_create() offered by iotests.py.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/210 | 81 +++++++++++++++++++-----------------------
 1 file changed, 36 insertions(+), 45 deletions(-)
diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210
index 565e3b7b9b..4ca0fe26ef 100755
--- a/tests/qemu-iotests/210
+++ b/tests/qemu-iotests/210
@@ -26,15 +26,6 @@ from iotests import imgfmt
 iotests.verify_image_format(supported_fmts=['luks'])
 iotests.verify_protocol(supported=['file'])
 
-def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
-                        filters=[iotests.filter_qmp_testfiles])
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-    iotests.log("")
-
 with iotests.FilePath('t.luks') as disk_path, \
      iotests.VM() as vm:
 
@@ -49,18 +40,18 @@ with iotests.FilePath('t.luks') as disk_path, \
     size = 128 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
 
     vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
                node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'imgfile',
-                          'key-secret': 'keysec0',
-                          'size': size,
-                          'iter-time': 10 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'imgfile',
+                         'key-secret': 'keysec0',
+                         'size': size,
+                         'iter-time': 10 })
     vm.shutdown()
 
     # TODO Proper support for images to be used with imgopts and/or protocols
@@ -79,22 +70,22 @@ with iotests.FilePath('t.luks') as disk_path, \
     size = 64 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'key-secret': 'keysec0',
-                          'cipher-alg': 'twofish-128',
-                          'cipher-mode': 'ctr',
-                          'ivgen-alg': 'plain64',
-                          'ivgen-hash-alg': 'md5',
-                          'hash-alg': 'sha1',
-                          'iter-time': 10 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'key-secret': 'keysec0',
+                         'cipher-alg': 'twofish-128',
+                         'cipher-mode': 'ctr',
+                         'ivgen-alg': 'plain64',
+                         'ivgen-hash-alg': 'md5',
+                         'hash-alg': 'sha1',
+                         'iter-time': 10 })
     vm.shutdown()
 
     # TODO Proper support for images to be used with imgopts and/or protocols
@@ -113,9 +104,9 @@ with iotests.FilePath('t.luks') as disk_path, \
     size = 64 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': "this doesn't exist",
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': "this doesn't exist",
+                         'size': size })
     vm.shutdown()
 
     #
@@ -126,11 +117,11 @@ with iotests.FilePath('t.luks') as disk_path, \
 
     vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'key-secret': 'keysec0',
-                          'size': 0,
-                          'iter-time': 10 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'key-secret': 'keysec0',
+                         'size': 0,
+                         'iter-time': 10 })
     vm.shutdown()
 
     # TODO Proper support for images to be used with imgopts and/or protocols
@@ -157,10 +148,10 @@ with iotests.FilePath('t.luks') as disk_path, \
 
     vm.launch()
     for size in [ 18446744073709551104, 9223372036854775808, 9223372036854775296 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'key-secret': 'keysec0',
-                              'size': size })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'key-secret': 'keysec0',
+                             'size': size })
     vm.shutdown()
 
     #
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 05/10] iotests: 212: Convert to VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
                   ` (3 preceding siblings ...)
  2019-12-16 17:08 ` [PATCH 04/10] iotests: 210: " Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 06/10] iotests: 213: " Kevin Wolf
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
Instead of having a separate blockdev_create() function, make use of the
VM.blockdev_create() offered by iotests.py.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/212 | 101 +++++++++++++++++++----------------------
 1 file changed, 46 insertions(+), 55 deletions(-)
diff --git a/tests/qemu-iotests/212 b/tests/qemu-iotests/212
index 42b74f208b..8f3ccc7b15 100755
--- a/tests/qemu-iotests/212
+++ b/tests/qemu-iotests/212
@@ -26,15 +26,6 @@ from iotests import imgfmt
 iotests.verify_image_format(supported_fmts=['parallels'])
 iotests.verify_protocol(supported=['file'])
 
-def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
-                        filters=[iotests.filter_qmp_testfiles])
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-    iotests.log("")
-
 with iotests.FilePath('t.parallels') as disk_path, \
      iotests.VM() as vm:
 
@@ -47,16 +38,16 @@ with iotests.FilePath('t.parallels') as disk_path, \
     size = 128 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
 
     vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
                node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'imgfile',
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'imgfile',
+                         'size': size })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -71,16 +62,16 @@ with iotests.FilePath('t.parallels') as disk_path, \
     size = 64 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'cluster-size': 1048576 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'cluster-size': 1048576 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -95,16 +86,16 @@ with iotests.FilePath('t.parallels') as disk_path, \
     size = 32 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'cluster-size': 65536 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'cluster-size': 65536 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -116,9 +107,9 @@ with iotests.FilePath('t.parallels') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': "this doesn't exist",
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': "this doesn't exist",
+                         'size': size })
     vm.shutdown()
 
     #
@@ -129,9 +120,9 @@ with iotests.FilePath('t.parallels') as disk_path, \
 
     vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 0 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -143,9 +134,9 @@ with iotests.FilePath('t.parallels') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 4503599627369984})
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 4503599627369984})
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -171,9 +162,9 @@ with iotests.FilePath('t.parallels') as disk_path, \
     vm.launch()
     for size in [ 1234, 18446744073709551104, 9223372036854775808,
                   9223372036854775296, 4503599627370497 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': size })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': size })
     vm.shutdown()
 
     #
@@ -185,12 +176,12 @@ with iotests.FilePath('t.parallels') as disk_path, \
     vm.launch()
     for csize in [ 1234, 128, 4294967296, 9223372036854775808,
                    18446744073709551104, 0 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': 67108864,
-                              'cluster-size': csize })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 281474976710656,
-                          'cluster-size': 512 })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': 67108864,
+                             'cluster-size': csize })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 281474976710656,
+                         'cluster-size': 512 })
     vm.shutdown()
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 06/10] iotests: 213: Convert to VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
                   ` (4 preceding siblings ...)
  2019-12-16 17:08 ` [PATCH 05/10] iotests: 212: " Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 07/10] iotests: 237: " Kevin Wolf
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
Instead of having a separate blockdev_create() function, make use of the
VM.blockdev_create() offered by iotests.py.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/213 | 113 +++++++++++++++++++----------------------
 1 file changed, 52 insertions(+), 61 deletions(-)
diff --git a/tests/qemu-iotests/213 b/tests/qemu-iotests/213
index 5604f3cebb..3fc8dc6eaa 100755
--- a/tests/qemu-iotests/213
+++ b/tests/qemu-iotests/213
@@ -26,15 +26,6 @@ from iotests import imgfmt
 iotests.verify_image_format(supported_fmts=['vhdx'])
 iotests.verify_protocol(supported=['file'])
 
-def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
-                        filters=[iotests.filter_qmp_testfiles])
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-    iotests.log("")
-
 with iotests.FilePath('t.vhdx') as disk_path, \
      iotests.VM() as vm:
 
@@ -47,16 +38,16 @@ with iotests.FilePath('t.vhdx') as disk_path, \
     size = 128 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
 
     vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
                node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'imgfile',
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'imgfile',
+                         'size': size })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -71,19 +62,19 @@ with iotests.FilePath('t.vhdx') as disk_path, \
     size = 64 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'log-size': 1048576,
-                          'block-size': 8388608,
-                          'subformat': 'dynamic',
-                          'block-state-zero': True })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'log-size': 1048576,
+                         'block-size': 8388608,
+                         'subformat': 'dynamic',
+                         'block-state-zero': True })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -98,19 +89,19 @@ with iotests.FilePath('t.vhdx') as disk_path, \
     size = 32 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'log-size': 8388608,
-                          'block-size': 268435456,
-                          'subformat': 'fixed',
-                          'block-state-zero': False })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'log-size': 8388608,
+                         'block-size': 268435456,
+                         'subformat': 'fixed',
+                         'block-state-zero': False })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -122,9 +113,9 @@ with iotests.FilePath('t.vhdx') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': "this doesn't exist",
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': "this doesn't exist",
+                         'size': size })
     vm.shutdown()
 
     #
@@ -135,9 +126,9 @@ with iotests.FilePath('t.vhdx') as disk_path, \
 
     vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 0 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -149,9 +140,9 @@ with iotests.FilePath('t.vhdx') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 70368744177664 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 70368744177664 })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -176,9 +167,9 @@ with iotests.FilePath('t.vhdx') as disk_path, \
     vm.launch()
     for size in [ 18446744073709551104, 9223372036854775808,
                   9223372036854775296, 70368744177665 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': size })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': size })
     vm.shutdown()
 
     #
@@ -189,10 +180,10 @@ with iotests.FilePath('t.vhdx') as disk_path, \
 
     vm.launch()
     for bsize in [ 1234567, 128, 3145728, 536870912, 0 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': 67108864,
-                              'block-size': bsize })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': 67108864,
+                             'block-size': bsize })
     vm.shutdown()
 
     #
@@ -203,8 +194,8 @@ with iotests.FilePath('t.vhdx') as disk_path, \
 
     vm.launch()
     for lsize in [ 1234567, 128, 4294967296, 0 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': 67108864,
-                              'log-size': lsize })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': 67108864,
+                             'log-size': lsize })
     vm.shutdown()
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 07/10] iotests: 237: Convert to VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
                   ` (5 preceding siblings ...)
  2019-12-16 17:08 ` [PATCH 06/10] iotests: 213: " Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 08/10] iotests: 266: " Kevin Wolf
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
Instead of having a separate blockdev_create() function, make use of the
VM.blockdev_create() offered by iotests.py.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/237 | 139 +++++++++++++++++++----------------------
 1 file changed, 65 insertions(+), 74 deletions(-)
diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237
index 06897f8c87..a2242a4736 100755
--- a/tests/qemu-iotests/237
+++ b/tests/qemu-iotests/237
@@ -26,15 +26,6 @@ from iotests import imgfmt
 
 iotests.verify_image_format(supported_fmts=['vmdk'])
 
-def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
-                        filters=[iotests.filter_qmp_testfiles])
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-    iotests.log("")
-
 with iotests.FilePath('t.vmdk') as disk_path, \
      iotests.FilePath('t.vmdk.1') as extent1_path, \
      iotests.FilePath('t.vmdk.2') as extent2_path, \
@@ -50,16 +41,16 @@ with iotests.FilePath('t.vmdk') as disk_path, \
     size = 5 * 1024 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
 
     vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
                node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'imgfile',
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'imgfile',
+                         'size': size })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -74,21 +65,21 @@ with iotests.FilePath('t.vmdk') as disk_path, \
     size = 64 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'extents': [],
-                          'subformat': 'monolithicSparse',
-                          'adapter-type': 'ide',
-                          'hwversion': '4',
-                          'zeroed-grain': False })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'extents': [],
+                         'subformat': 'monolithicSparse',
+                         'adapter-type': 'ide',
+                         'hwversion': '4',
+                         'zeroed-grain': False })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -103,20 +94,20 @@ with iotests.FilePath('t.vmdk') as disk_path, \
     size = 32 * 1024 * 1024
 
     vm.launch()
-    blockdev_create(vm, { 'driver': 'file',
-                          'filename': disk_path,
-                          'size': 0 })
-
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': {
-                              'driver': 'file',
-                              'filename': disk_path,
-                          },
-                          'size': size,
-                          'extents': [],
-                          'subformat': 'monolithicSparse',
-                          'adapter-type': 'buslogic',
-                          'zeroed-grain': True })
+    vm.blockdev_create({ 'driver': 'file',
+                         'filename': disk_path,
+                         'size': 0 })
+
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': {
+                             'driver': 'file',
+                             'filename': disk_path,
+                         },
+                         'size': size,
+                         'extents': [],
+                         'subformat': 'monolithicSparse',
+                         'adapter-type': 'buslogic',
+                         'zeroed-grain': True })
     vm.shutdown()
 
     iotests.img_info_log(disk_path)
@@ -128,9 +119,9 @@ with iotests.FilePath('t.vmdk') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': "this doesn't exist",
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': "this doesn't exist",
+                         'size': size })
     vm.shutdown()
 
     #
@@ -148,10 +139,10 @@ with iotests.FilePath('t.vmdk') as disk_path, \
 
     vm.launch()
     for adapter_type in [ 'ide', 'buslogic', 'lsilogic', 'legacyESX' ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': size,
-                              'adapter-type': adapter_type })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': size,
+                             'adapter-type': adapter_type })
     vm.shutdown()
 
     # Invalid
@@ -160,10 +151,10 @@ with iotests.FilePath('t.vmdk') as disk_path, \
 
     vm.launch()
     for adapter_type in [ 'foo', 'IDE', 'legacyesx', 1 ]:
-        blockdev_create(vm, { 'driver': imgfmt,
-                              'file': 'node0',
-                              'size': size,
-                              'adapter-type': adapter_type })
+        vm.blockdev_create({ 'driver': imgfmt,
+                             'file': 'node0',
+                             'size': size,
+                             'adapter-type': adapter_type })
     vm.shutdown()
 
     #
@@ -185,10 +176,10 @@ with iotests.FilePath('t.vmdk') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': size,
-                          'subformat': 'monolithicFlat' })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': size,
+                         'subformat': 'monolithicFlat' })
     vm.shutdown()
 
     # Correct extent
@@ -196,11 +187,11 @@ with iotests.FilePath('t.vmdk') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': size,
-                          'subformat': 'monolithicFlat',
-                          'extents': ['ext1'] })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': size,
+                         'subformat': 'monolithicFlat',
+                         'extents': ['ext1'] })
     vm.shutdown()
 
     # Extra extent
@@ -208,11 +199,11 @@ with iotests.FilePath('t.vmdk') as disk_path, \
     iotests.log("")
 
     vm.launch()
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'node0',
-                          'size': 512,
-                          'subformat': 'monolithicFlat',
-                          'extents': ['ext1', 'ext2', 'ext3'] })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'node0',
+                         'size': 512,
+                         'subformat': 'monolithicFlat',
+                         'extents': ['ext1', 'ext2', 'ext3'] })
     vm.shutdown()
 
     # Split formats
@@ -228,11 +219,11 @@ with iotests.FilePath('t.vmdk') as disk_path, \
             extents = [ "ext%d" % (i) for i in range(1, num_extents + 1) ]
 
             vm.launch()
-            blockdev_create(vm, { 'driver': imgfmt,
-                                  'file': 'node0',
-                                  'size': size,
-                                  'subformat': subfmt,
-                                  'extents': extents })
+            vm.blockdev_create({ 'driver': imgfmt,
+                                 'file': 'node0',
+                                 'size': size,
+                                 'subformat': subfmt,
+                                 'extents': extents })
             vm.shutdown()
 
             iotests.img_info_log(disk_path)
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 08/10] iotests: 266: Convert to VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
                   ` (6 preceding siblings ...)
  2019-12-16 17:08 ` [PATCH 07/10] iotests: 237: " Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 09/10] iotests: 207: Remove duplication with VM.blockdev_create() Kevin Wolf
  2019-12-16 17:08 ` [PATCH 10/10] iotests: 211: " Kevin Wolf
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
Instead of having a separate blockdev_create() function, make use of the
VM.blockdev_create() offered by iotests.py.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/266     | 69 +++++++++++++++++---------------------
 tests/qemu-iotests/266.out | 14 ++++++++
 2 files changed, 44 insertions(+), 39 deletions(-)
diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266
index 5b35cd67e4..c353cf88ee 100755
--- a/tests/qemu-iotests/266
+++ b/tests/qemu-iotests/266
@@ -22,15 +22,6 @@ import iotests
 from iotests import imgfmt
 
 
-def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
-                        filters=[iotests.filter_qmp_testfiles])
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-
-
 # Successful image creation (defaults)
 def implicit_defaults(vm, file_path):
     iotests.log("=== Successful image creation (defaults) ===")
@@ -40,9 +31,9 @@ def implicit_defaults(vm, file_path):
     # (Close to 64 MB)
     size = 8 * 964 * 17 * 512
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'protocol-node',
-                          'size': size })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'protocol-node',
+                         'size': size })
 
 
 # Successful image creation (explicit defaults)
@@ -54,11 +45,11 @@ def explicit_defaults(vm, file_path):
     # (Close to 128 MB)
     size = 16 * 964 * 17 * 512
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'protocol-node',
-                          'size': size,
-                          'subformat': 'dynamic',
-                          'force-size': False })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'protocol-node',
+                         'size': size,
+                         'subformat': 'dynamic',
+                         'force-size': False })
 
 
 # Successful image creation (non-default options)
@@ -69,11 +60,11 @@ def non_defaults(vm, file_path):
     # Not representable in CHS (fine with force-size=True)
     size = 1048576
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'protocol-node',
-                          'size': size,
-                          'subformat': 'fixed',
-                          'force-size': True })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'protocol-node',
+                         'size': size,
+                         'subformat': 'fixed',
+                         'force-size': True })
 
 
 # Size not representable in CHS with force-size=False
@@ -84,10 +75,10 @@ def non_chs_size_without_force(vm, file_path):
     # Not representable in CHS (will not work with force-size=False)
     size = 1048576
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'protocol-node',
-                          'size': size,
-                          'force-size': False })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'protocol-node',
+                         'size': size,
+                         'force-size': False })
 
 
 # Zero size
@@ -95,9 +86,9 @@ def zero_size(vm, file_path):
     iotests.log("=== Zero size===")
     iotests.log("")
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'protocol-node',
-                          'size': 0 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'protocol-node',
+                         'size': 0 })
 
 
 # Maximum CHS size
@@ -105,9 +96,9 @@ def maximum_chs_size(vm, file_path):
     iotests.log("=== Maximum CHS size===")
     iotests.log("")
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'protocol-node',
-                          'size': 16 * 65535 * 255 * 512 })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'protocol-node',
+                         'size': 16 * 65535 * 255 * 512 })
 
 
 # Actual maximum size
@@ -115,10 +106,10 @@ def maximum_size(vm, file_path):
     iotests.log("=== Actual maximum size===")
     iotests.log("")
 
-    blockdev_create(vm, { 'driver': imgfmt,
-                          'file': 'protocol-node',
-                          'size': 0xff000000 * 512,
-                          'force-size': True })
+    vm.blockdev_create({ 'driver': imgfmt,
+                         'file': 'protocol-node',
+                         'size': 0xff000000 * 512,
+                         'force-size': True })
 
 
 def main():
@@ -132,9 +123,9 @@ def main():
             vm.launch()
 
             iotests.log('--- Creating empty file ---')
-            blockdev_create(vm, { 'driver': 'file',
-                                  'filename': file_path,
-                                  'size': 0 })
+            vm.blockdev_create({ 'driver': 'file',
+                                 'filename': file_path,
+                                 'size': 0 })
 
             vm.qmp_log('blockdev-add', driver='file', filename=file_path,
                        node_name='protocol-node',
diff --git a/tests/qemu-iotests/266.out b/tests/qemu-iotests/266.out
index b11953e81f..5a7d7d01aa 100644
--- a/tests/qemu-iotests/266.out
+++ b/tests/qemu-iotests/266.out
@@ -3,6 +3,7 @@
 {"return": {}}
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
+
 {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
 {"return": {}}
 
@@ -13,6 +14,7 @@
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
 
+
 image: TEST_IMG
 file format: IMGFMT
 virtual size: 64 MiB (67125248 bytes)
@@ -23,6 +25,7 @@ cluster_size: 2097152
 {"return": {}}
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
+
 {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
 {"return": {}}
 
@@ -33,6 +36,7 @@ cluster_size: 2097152
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
 
+
 image: TEST_IMG
 file format: IMGFMT
 virtual size: 128 MiB (134250496 bytes)
@@ -43,6 +47,7 @@ cluster_size: 2097152
 {"return": {}}
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
+
 {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
 {"return": {}}
 
@@ -53,6 +58,7 @@ cluster_size: 2097152
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
 
+
 image: TEST_IMG
 file format: IMGFMT
 virtual size: 1 MiB (1048576 bytes)
@@ -62,6 +68,7 @@ virtual size: 1 MiB (1048576 bytes)
 {"return": {}}
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
+
 {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
 {"return": {}}
 
@@ -73,6 +80,7 @@ Job failed: The requested image size cannot be represented in CHS geometry
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
 
+
 qemu-img: Could not open 'TEST_IMG': File too small for a VHD header
 
 --- Creating empty file ---
@@ -80,6 +88,7 @@ qemu-img: Could not open 'TEST_IMG': File too small for a VHD header
 {"return": {}}
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
+
 {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
 {"return": {}}
 
@@ -90,6 +99,7 @@ qemu-img: Could not open 'TEST_IMG': File too small for a VHD header
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
 
+
 image: TEST_IMG
 file format: IMGFMT
 virtual size: 0 B (0 bytes)
@@ -100,6 +110,7 @@ cluster_size: 2097152
 {"return": {}}
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
+
 {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
 {"return": {}}
 
@@ -110,6 +121,7 @@ cluster_size: 2097152
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
 
+
 image: TEST_IMG
 file format: IMGFMT
 virtual size: 127 GiB (136899993600 bytes)
@@ -120,6 +132,7 @@ cluster_size: 2097152
 {"return": {}}
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
+
 {"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
 {"return": {}}
 
@@ -130,6 +143,7 @@ cluster_size: 2097152
 {"execute": "job-dismiss", "arguments": {"id": "job0"}}
 {"return": {}}
 
+
 image: TEST_IMG
 file format: IMGFMT
 virtual size: 1.99 TiB (2190433320960 bytes)
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 09/10] iotests: 207: Remove duplication with VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
                   ` (7 preceding siblings ...)
  2019-12-16 17:08 ` [PATCH 08/10] iotests: 266: " Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  2019-12-16 17:08 ` [PATCH 10/10] iotests: 211: " Kevin Wolf
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
The blockdev_create() function in this test case adds another filter to
the logging, but provides otherwise the same functionality as
VM.blockdev_create() from iotests.py. Make it a thin wrapper around the
iotests.py function.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/207 | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
index ec8c1d06f0..812ab34e47 100755
--- a/tests/qemu-iotests/207
+++ b/tests/qemu-iotests/207
@@ -35,13 +35,7 @@ def filter_hash(qmsg):
     return iotests.filter_qmp(qmsg, _filter)
 
 def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
-                        filters=[iotests.filter_qmp_testfiles, filter_hash])
-
-    if 'return' in result:
-        assert result['return'] == {}
-        vm.run_job('job0')
-    iotests.log("")
+    vm.blockdev_create(options, filters=[iotests.filter_qmp_testfiles, filter_hash])
 
 with iotests.FilePath('t.img') as disk_path, \
      iotests.VM() as vm:
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread
- * [PATCH 10/10] iotests: 211: Remove duplication with VM.blockdev_create()
  2019-12-16 17:08 [PATCH 00/10] iotests: Remove duplicated blockdev_create() Kevin Wolf
                   ` (8 preceding siblings ...)
  2019-12-16 17:08 ` [PATCH 09/10] iotests: 207: Remove duplication with VM.blockdev_create() Kevin Wolf
@ 2019-12-16 17:08 ` Kevin Wolf
  9 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2019-12-16 17:08 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
The blockdev_create() function in this test case adds an error check
that skips the test in case of failure because of memory shortage, but
provides otherwise the same functionality as VM.blockdev_create() from
iotests.py. Make it a thin wrapper around the iotests.py function.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/211 | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
index 6afc894f76..8834ebfe85 100755
--- a/tests/qemu-iotests/211
+++ b/tests/qemu-iotests/211
@@ -27,15 +27,9 @@ iotests.verify_image_format(supported_fmts=['vdi'])
 iotests.verify_protocol(supported=['file'])
 
 def blockdev_create(vm, options):
-    result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
-                        filters=[iotests.filter_qmp_testfiles])
-
-    if 'return' in result:
-        assert result['return'] == {}
-        error = vm.run_job('job0')
-        if error and 'Could not allocate bmap' in error:
-            iotests.notrun('Insufficient memory')
-    iotests.log("")
+    error = vm.blockdev_create(options)
+    if error and 'Could not allocate bmap' in error:
+        iotests.notrun('Insufficient memory')
 
 with iotests.FilePath('t.vdi') as disk_path, \
      iotests.VM() as vm:
-- 
2.20.1
^ permalink raw reply related	[flat|nested] 11+ messages in thread