iotests: Introduce qemu_nbd_list_log()
Add a function to list the NBD exports offered by an NBD server. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20200924152717.287415-30-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
91efbae938
commit
81b6b2bc1a
@ -65,7 +65,8 @@ if os.environ.get('QEMU_IO_OPTIONS_NO_FMT'):
|
|||||||
qemu_io_args_no_fmt += \
|
qemu_io_args_no_fmt += \
|
||||||
os.environ['QEMU_IO_OPTIONS_NO_FMT'].strip().split(' ')
|
os.environ['QEMU_IO_OPTIONS_NO_FMT'].strip().split(' ')
|
||||||
|
|
||||||
qemu_nbd_args = [os.environ.get('QEMU_NBD_PROG', 'qemu-nbd')]
|
qemu_nbd_prog = os.environ.get('QEMU_NBD_PROG', 'qemu-nbd')
|
||||||
|
qemu_nbd_args = [qemu_nbd_prog]
|
||||||
if os.environ.get('QEMU_NBD_OPTIONS'):
|
if os.environ.get('QEMU_NBD_OPTIONS'):
|
||||||
qemu_nbd_args += os.environ['QEMU_NBD_OPTIONS'].strip().split(' ')
|
qemu_nbd_args += os.environ['QEMU_NBD_OPTIONS'].strip().split(' ')
|
||||||
|
|
||||||
@ -280,6 +281,13 @@ def qemu_nbd_early_pipe(*args: str) -> Tuple[int, str]:
|
|||||||
connect_stderr=False)
|
connect_stderr=False)
|
||||||
return returncode, output if returncode else ''
|
return returncode, output if returncode else ''
|
||||||
|
|
||||||
|
def qemu_nbd_list_log(*args: str) -> str:
|
||||||
|
'''Run qemu-nbd to list remote exports'''
|
||||||
|
full_args = [qemu_nbd_prog, '-L'] + list(args)
|
||||||
|
output, _ = qemu_tool_pipe_and_status('qemu-nbd', full_args)
|
||||||
|
log(output, filters=[filter_testfiles, filter_nbd_exports])
|
||||||
|
return output
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def qemu_nbd_popen(*args):
|
def qemu_nbd_popen(*args):
|
||||||
'''Context manager running qemu-nbd within the context'''
|
'''Context manager running qemu-nbd within the context'''
|
||||||
@ -413,6 +421,9 @@ def filter_qmp_imgfmt(qmsg):
|
|||||||
return value
|
return value
|
||||||
return filter_qmp(qmsg, _filter)
|
return filter_qmp(qmsg, _filter)
|
||||||
|
|
||||||
|
def filter_nbd_exports(output: str) -> str:
|
||||||
|
return re.sub(r'((min|opt|max) block): [0-9]+', r'\1: XXX', output)
|
||||||
|
|
||||||
|
|
||||||
Msg = TypeVar('Msg', Dict[str, Any], List[Any], str)
|
Msg = TypeVar('Msg', Dict[str, Any], List[Any], str)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user