mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
iotests: remove qemu_io_silent() and qemu_io_silent_check().
Like qemu-img, qemu-io returning 0 should be the norm and not the exception. Remove all calls to qemu_io_silent that just assert the return code is zero (That's every last call, as it turns out), and replace them with a normal qemu_io() call. qemu_io_silent_check() appeared to have been unused already. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220418211504.943969-12-jsnow@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
parent
23d44dcb7c
commit
72cfb937b8
|
@ -21,7 +21,7 @@
|
|||
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
|
||||
|
||||
import iotests
|
||||
from iotests import log, qemu_img, qemu_io_silent
|
||||
from iotests import log, qemu_img, qemu_io
|
||||
|
||||
# Need backing file support
|
||||
iotests.script_initialize(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'],
|
||||
|
@ -52,10 +52,10 @@ with iotests.FilePath('base.img') as base_img_path, \
|
|||
log('')
|
||||
|
||||
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
||||
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
|
||||
qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path)
|
||||
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
|
||||
qemu_io(top_img_path, '-c', 'write -P 2 1M 1M')
|
||||
|
||||
log('Done')
|
||||
|
||||
|
@ -110,8 +110,8 @@ with iotests.FilePath('base.img') as base_img_path, \
|
|||
log('--- Checking COR result ---')
|
||||
log('')
|
||||
|
||||
assert qemu_io_silent(base_img_path, '-c', 'discard 0 64M') == 0
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 1 0M 1M') == 0
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
|
||||
qemu_io(base_img_path, '-c', 'discard 0 64M')
|
||||
qemu_io(top_img_path, '-c', 'read -P 1 0M 1M')
|
||||
qemu_io(top_img_path, '-c', 'read -P 2 1M 1M')
|
||||
|
||||
log('Done')
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
|
||||
|
||||
import iotests
|
||||
from iotests import log, qemu_img, qemu_io_silent
|
||||
from iotests import log, qemu_img, qemu_io
|
||||
|
||||
iotests.script_initialize(supported_fmts=['qcow2', 'raw'])
|
||||
|
||||
|
@ -146,8 +146,7 @@ with iotests.VM() as vm, \
|
|||
iotests.FilePath('src.img') as src_img_path:
|
||||
|
||||
qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M')
|
||||
assert qemu_io_silent('-f', iotests.imgfmt, src_img_path,
|
||||
'-c', 'write -P 42 0M 64M') == 0
|
||||
qemu_io('-f', iotests.imgfmt, src_img_path, '-c', 'write -P 42 0M 64M')
|
||||
|
||||
vm.launch()
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
|
||||
|
||||
import iotests
|
||||
from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \
|
||||
from iotests import log, qemu_img, qemu_io, filter_qmp_testfiles, \
|
||||
filter_qmp_imgfmt
|
||||
import json
|
||||
|
||||
|
@ -54,7 +54,7 @@ for filter_node_name in False, True:
|
|||
'-F', iotests.imgfmt, top_img_path)
|
||||
|
||||
# Something to commit
|
||||
assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') == 0
|
||||
qemu_io(mid_img_path, '-c', 'write -P 1 0 1M')
|
||||
|
||||
vm.launch()
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# Creator/Owner: Hanna Reitz <hreitz@redhat.com>
|
||||
|
||||
import iotests
|
||||
from iotests import log, qemu_img, qemu_io_silent, \
|
||||
from iotests import log, qemu_img, qemu_io, \
|
||||
filter_qmp_testfiles, filter_qmp_imgfmt
|
||||
|
||||
# Returns a node for blockdev-add
|
||||
|
@ -86,15 +86,14 @@ def test_concurrent_finish(write_to_stream_node):
|
|||
if write_to_stream_node:
|
||||
# This is what (most of the time) makes commit finish
|
||||
# earlier and then pull in stream
|
||||
assert qemu_io_silent(node2_path,
|
||||
'-c', 'write %iK 64K' % (65536 - 192),
|
||||
'-c', 'write %iK 64K' % (65536 - 64)) == 0
|
||||
qemu_io(node2_path,
|
||||
'-c', 'write %iK 64K' % (65536 - 192),
|
||||
'-c', 'write %iK 64K' % (65536 - 64))
|
||||
|
||||
stream_throttle='tg'
|
||||
else:
|
||||
# And this makes stream finish earlier
|
||||
assert qemu_io_silent(node1_path,
|
||||
'-c', 'write %iK 64K' % (65536 - 64)) == 0
|
||||
qemu_io(node1_path, '-c', 'write %iK 64K' % (65536 - 64))
|
||||
|
||||
commit_throttle='tg'
|
||||
|
||||
|
|
|
@ -129,16 +129,13 @@ class TestTruncate(iotests.QMPTestCase):
|
|||
os.remove(refdisk)
|
||||
|
||||
def do_test(self, prealloc_mode, new_size):
|
||||
ret = iotests.qemu_io_silent('--image-opts', '-c', 'write 0 10M', '-c',
|
||||
f'truncate -m {prealloc_mode} {new_size}',
|
||||
drive_opts)
|
||||
self.assertEqual(ret, 0)
|
||||
iotests.qemu_io('--image-opts', '-c', 'write 0 10M', '-c',
|
||||
f'truncate -m {prealloc_mode} {new_size}',
|
||||
drive_opts)
|
||||
|
||||
ret = iotests.qemu_io_silent('-f', iotests.imgfmt, '-c', 'write 0 10M',
|
||||
'-c',
|
||||
f'truncate -m {prealloc_mode} {new_size}',
|
||||
refdisk)
|
||||
self.assertEqual(ret, 0)
|
||||
iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 10M',
|
||||
'-c', f'truncate -m {prealloc_mode} {new_size}',
|
||||
refdisk)
|
||||
|
||||
stat = os.stat(disk)
|
||||
refstat = os.stat(refdisk)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
|
||||
import iotests
|
||||
from iotests import log, qemu_img, qemu_io_silent
|
||||
from iotests import log, qemu_img, qemu_io
|
||||
|
||||
# Need backing file support
|
||||
iotests.script_initialize(supported_fmts=['qcow2'],
|
||||
|
@ -44,15 +44,15 @@ with iotests.FilePath('base.img') as base_img_path, \
|
|||
log('')
|
||||
|
||||
qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
||||
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
|
||||
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0
|
||||
qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')
|
||||
qemu_io(base_img_path, '-c', 'write -P 1 3M 1M')
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
||||
'-F', iotests.imgfmt, mid_img_path)
|
||||
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
|
||||
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
|
||||
qemu_io(mid_img_path, '-c', 'write -P 3 2M 1M')
|
||||
qemu_io(mid_img_path, '-c', 'write -P 3 4M 1M')
|
||||
qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
|
||||
'-F', iotests.imgfmt, top_img_path)
|
||||
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
|
||||
qemu_io(top_img_path, '-c', 'write -P 2 1M 1M')
|
||||
|
||||
# 0 1 2 3 4
|
||||
# top 2
|
||||
|
@ -107,10 +107,10 @@ with iotests.FilePath('base.img') as base_img_path, \
|
|||
# Detach backing to check that we can read the data from the top level now
|
||||
qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, top_img_path)
|
||||
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 3 2M 1M') == 0
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 0 3M 1M') == 0
|
||||
assert qemu_io_silent(top_img_path, '-c', 'read -P 3 4M 1M') == 0
|
||||
qemu_io(top_img_path, '-c', 'read -P 0 0 1M')
|
||||
qemu_io(top_img_path, '-c', 'read -P 2 1M 1M')
|
||||
qemu_io(top_img_path, '-c', 'read -P 3 2M 1M')
|
||||
qemu_io(top_img_path, '-c', 'read -P 0 3M 1M')
|
||||
qemu_io(top_img_path, '-c', 'read -P 3 4M 1M')
|
||||
|
||||
log('Done')
|
||||
|
|
|
@ -369,22 +369,6 @@ def qemu_io_log(*args: str) -> 'subprocess.CompletedProcess[str]':
|
|||
log(result.stdout, filters=[filter_testfiles, filter_qemu_io])
|
||||
return result
|
||||
|
||||
def qemu_io_silent(*args):
|
||||
'''Run qemu-io and return the exit code, suppressing stdout'''
|
||||
args = qemu_io_wrap_args(args)
|
||||
result = subprocess.run(args, stdout=subprocess.DEVNULL, check=False)
|
||||
if result.returncode < 0:
|
||||
sys.stderr.write('qemu-io received signal %i: %s\n' %
|
||||
(-result.returncode, ' '.join(args)))
|
||||
return result.returncode
|
||||
|
||||
def qemu_io_silent_check(*args):
|
||||
'''Run qemu-io and return the true if subprocess returned 0'''
|
||||
args = qemu_io_wrap_args(args)
|
||||
result = subprocess.run(args, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.STDOUT, check=False)
|
||||
return result.returncode == 0
|
||||
|
||||
class QemuIoInteractive:
|
||||
def __init__(self, *args):
|
||||
self.args = qemu_io_wrap_args(args)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
from subprocess import CalledProcessError
|
||||
|
||||
import iotests
|
||||
from iotests import log, qemu_img, qemu_io, qemu_io_silent
|
||||
from iotests import log, qemu_img, qemu_io
|
||||
|
||||
iotests.script_initialize(
|
||||
supported_fmts=['qcow2'],
|
||||
|
@ -270,7 +270,7 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base_img_path,
|
|||
for p in overwrite + remainder:
|
||||
cmd = 'read -P%s %s %s' % p
|
||||
log(cmd)
|
||||
assert qemu_io_silent(base_img_path, '-c', cmd) == 0
|
||||
qemu_io(base_img_path, '-c', cmd)
|
||||
|
||||
log('')
|
||||
log('Done')
|
||||
|
|
|
@ -37,7 +37,7 @@ class TestMirrorReadyCancelError(iotests.QMPTestCase):
|
|||
# Ensure that mirror will copy something before READY so the
|
||||
# target format layer will forward the pre-READY flush to its
|
||||
# file child
|
||||
assert iotests.qemu_io_silent('-c', 'write -P 1 0 64k', source) == 0
|
||||
iotests.qemu_io('-c', 'write -P 1 0 64k', source)
|
||||
|
||||
self.vm = iotests.VM()
|
||||
self.vm.launch()
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
import os
|
||||
import iotests
|
||||
from iotests import imgfmt, qemu_img_create, qemu_io_silent, QMPTestCase
|
||||
from iotests import imgfmt, qemu_img_create, qemu_io, QMPTestCase
|
||||
|
||||
|
||||
image_size = 1 * 1024 * 1024
|
||||
|
@ -55,7 +55,7 @@ class TestStreamErrorOnReset(QMPTestCase):
|
|||
- top image is attached to a virtio-scsi device
|
||||
"""
|
||||
qemu_img_create('-f', imgfmt, base, str(image_size))
|
||||
assert qemu_io_silent('-c', f'write 0 {data_size}', base) == 0
|
||||
qemu_io('-c', f'write 0 {data_size}', base)
|
||||
qemu_img_create('-f', imgfmt, top, str(image_size))
|
||||
|
||||
self.vm = iotests.VM()
|
||||
|
|
Loading…
Reference in a new issue