iotests.py: Add qemu_nbd function

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Max Reitz 2016-10-25 15:11:37 +02:00 committed by Kevin Wolf
parent 6b02b1f0a4
commit bec87774c2
1 changed files with 8 additions and 0 deletions

View File

@ -39,6 +39,10 @@
if os.environ.get('QEMU_IO_OPTIONS'): if os.environ.get('QEMU_IO_OPTIONS'):
qemu_io_args += os.environ['QEMU_IO_OPTIONS'].strip().split(' ') qemu_io_args += os.environ['QEMU_IO_OPTIONS'].strip().split(' ')
qemu_nbd_args = [os.environ.get('QEMU_NBD_PROG', 'qemu-nbd')]
if os.environ.get('QEMU_NBD_OPTIONS'):
qemu_nbd_args += os.environ['QEMU_NBD_OPTIONS'].strip().split(' ')
qemu_prog = os.environ.get('QEMU_PROG', 'qemu') qemu_prog = os.environ.get('QEMU_PROG', 'qemu')
qemu_opts = os.environ.get('QEMU_OPTIONS', '').strip().split(' ') qemu_opts = os.environ.get('QEMU_OPTIONS', '').strip().split(' ')
@ -87,6 +91,10 @@ def qemu_io(*args):
sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args)))
return subp.communicate()[0] return subp.communicate()[0]
def qemu_nbd(*args):
'''Run qemu-nbd in daemon mode and return the parent's exit code'''
return subprocess.call(qemu_nbd_args + ['--fork'] + list(args))
def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt): def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
'''Return True if two image files are identical''' '''Return True if two image files are identical'''
return qemu_img('compare', '-f', fmt1, return qemu_img('compare', '-f', fmt1,