iotests: 210: Convert to VM.blockdev_create()

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>
This commit is contained in:
Kevin Wolf 2019-12-16 17:57:19 +01:00
parent f6da17366a
commit e55c24138b

View File

@ -26,15 +26,6 @@ from iotests import imgfmt
iotests.verify_image_format(supported_fmts=['luks']) iotests.verify_image_format(supported_fmts=['luks'])
iotests.verify_protocol(supported=['file']) 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, \ with iotests.FilePath('t.luks') as disk_path, \
iotests.VM() as vm: iotests.VM() as vm:
@ -49,18 +40,18 @@ with iotests.FilePath('t.luks') as disk_path, \
size = 128 * 1024 * 1024 size = 128 * 1024 * 1024
vm.launch() vm.launch()
blockdev_create(vm, { 'driver': 'file', vm.blockdev_create({ 'driver': 'file',
'filename': disk_path, 'filename': disk_path,
'size': 0 }) 'size': 0 })
vm.qmp_log('blockdev-add', driver='file', filename=disk_path, vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
node_name='imgfile', filters=[iotests.filter_qmp_testfiles]) node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
blockdev_create(vm, { 'driver': imgfmt, vm.blockdev_create({ 'driver': imgfmt,
'file': 'imgfile', 'file': 'imgfile',
'key-secret': 'keysec0', 'key-secret': 'keysec0',
'size': size, 'size': size,
'iter-time': 10 }) 'iter-time': 10 })
vm.shutdown() vm.shutdown()
# TODO Proper support for images to be used with imgopts and/or protocols # 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 size = 64 * 1024 * 1024
vm.launch() vm.launch()
blockdev_create(vm, { 'driver': 'file', vm.blockdev_create({ 'driver': 'file',
'filename': disk_path, 'filename': disk_path,
'size': 0 }) 'size': 0 })
blockdev_create(vm, { 'driver': imgfmt, vm.blockdev_create({ 'driver': imgfmt,
'file': { 'file': {
'driver': 'file', 'driver': 'file',
'filename': disk_path, 'filename': disk_path,
}, },
'size': size, 'size': size,
'key-secret': 'keysec0', 'key-secret': 'keysec0',
'cipher-alg': 'twofish-128', 'cipher-alg': 'twofish-128',
'cipher-mode': 'ctr', 'cipher-mode': 'ctr',
'ivgen-alg': 'plain64', 'ivgen-alg': 'plain64',
'ivgen-hash-alg': 'md5', 'ivgen-hash-alg': 'md5',
'hash-alg': 'sha1', 'hash-alg': 'sha1',
'iter-time': 10 }) 'iter-time': 10 })
vm.shutdown() vm.shutdown()
# TODO Proper support for images to be used with imgopts and/or protocols # 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 size = 64 * 1024 * 1024
vm.launch() vm.launch()
blockdev_create(vm, { 'driver': imgfmt, vm.blockdev_create({ 'driver': imgfmt,
'file': "this doesn't exist", 'file': "this doesn't exist",
'size': size }) 'size': size })
vm.shutdown() 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.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
vm.launch() vm.launch()
blockdev_create(vm, { 'driver': imgfmt, vm.blockdev_create({ 'driver': imgfmt,
'file': 'node0', 'file': 'node0',
'key-secret': 'keysec0', 'key-secret': 'keysec0',
'size': 0, 'size': 0,
'iter-time': 10 }) 'iter-time': 10 })
vm.shutdown() vm.shutdown()
# TODO Proper support for images to be used with imgopts and/or protocols # 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() vm.launch()
for size in [ 18446744073709551104, 9223372036854775808, 9223372036854775296 ]: for size in [ 18446744073709551104, 9223372036854775808, 9223372036854775296 ]:
blockdev_create(vm, { 'driver': imgfmt, vm.blockdev_create({ 'driver': imgfmt,
'file': 'node0', 'file': 'node0',
'key-secret': 'keysec0', 'key-secret': 'keysec0',
'size': size }) 'size': size })
vm.shutdown() vm.shutdown()
# #