iotests: 205: support luks format
PATCH v2 1/1 iotests: 205: support luks format
Support default luks options in VM.add_drive and in new library function qemu_img_create. Use it in 205 iotests.
---
v2: use keysec0 and IMGKEYSECRET
tests/qemu-iotests/205 | 4 ++-- tests/qemu-iotests/iotests.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-)
tests/qemu-iotests/205 +2 -2
@@ -22,7 +22,7 @@ import os import sys import iotests import time -from iotests import qemu_img, qemu_io, filter_qemu_io, QemuIoInteractive +from iotests import qemu_img_create, qemu_io, filter_qemu_io, QemuIoInteractive nbd_sock = 'nbd_sock' nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock
@@ -31,7 +31,7 @@ disk = os.path.join(iotests.test_dir, 'disk') class TestNbdServerRemove(iotests.QMPTestCase): def setUp(self): - qemu_img('create', '-f', iotests.imgfmt, disk, '1M') + qemu_img_create('-f', iotests.imgfmt, disk, '1M') self.vm = iotests.VM().add_drive(disk) self.vm.launch()
tests/qemu-iotests/iotests.py +31 -0
@@ -58,6 +58,11 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') debug = False +luks_default_secret_object = 'secret,id=keysec0,data=' + \ + os.environ['IMGKEYSECRET'] +luks_default_key_secret_opt = 'key-secret=keysec0' + + def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull = open('/dev/null', 'r+')
@@ -66,6 +71,25 @@ def qemu_img(*args): sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) return exitcode +def qemu_img_create(*args): + args = list(args) + + # default luks support + if '-f' in args and args[args.index('-f') + 1] == 'luks': + if '-o' in args: + i = args.index('-o') + if 'key-secret' not in args[i + 1]: + args[i + 1].append(luks_default_key_secret_opt) + args.insert(i + 2, '--object') + args.insert(i + 3, luks_default_secret_object) + else: + args = ['-o', luks_default_key_secret_opt, + '--object', luks_default_secret_object] + args + + args.insert(0, 'create') + + return qemu_img(*args) + def qemu_img_verbose(*args): '''Run qemu-img without suppressing its output and return the exit code''' exitcode = subprocess.call(qemu_img_args + list(args))
@@ -263,6 +287,13 @@ class VM(qtest.QEMUQtestMachine): if opts: options.append(opts) + if format == 'luks' and 'key-secret' not in opts: + # default luks support + if luks_default_secret_object not in self._args: + self.add_object(luks_default_secret_object) + + options.append(luks_default_key_secret_opt) + self._args.append('-drive') self._args.append(','.join(options)) self._num_drives += 1
Signature · 1 line
2.11.1
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
Support default luks options in VM.add_drive and in new library function
qemu_img_create. Use it in 205 iotests.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 8 lines · Daniel P. Berrangé
Quoted 5 lines · Vladimir Sementsov-Ogievskiy
Support default luks options in VM.add_drive and in new library function
qemu_img_create. Use it in 205 iotests.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
Reviewed-by Daniel P. Berrange <[email protected]>
Thanks. I'll take this through my NBD queue.
git git://repo.or.cz/qemu/ericb.git nbd
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 5 lines · Eric Blake
Quoted 4 lines · Daniel P. Berrangé
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Support default luks options in VM.add_drive and in new library function
qemu_img_create. Use it in 205 iotests.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
Reviewed-by Daniel P. Berrange <[email protected]>Thanks. I'll take this through my NBD queue.
git
git://repo.or.cz/qemu/ericb.gitnbd
I'm seeing this failure now :(
$ ./check -luks 205 QEMU -- "/home/eblake/qemu/x86_64-softmmu/qemu-system-x86_64" -nodefaults -machine accel=qtest QEMU_IMG -- "/home/eblake/qemu/qemu-img" QEMU_IO -- "/home/eblake/qemu/qemu-io" --cache writeback QEMU_NBD -- "/home/eblake/qemu/qemu-nbd" IMGFMT -- luks (iter-time=10) IMGPROTO -- file PLATFORM -- Linux/x86_64 red 4.14.16-300.fc27.x86_64 TEST_DIR -- /home/eblake/qemu/tests/qemu-iotests/scratch SOCKET_SCM_HELPER -- /home/eblake/qemu/tests/qemu-iotests/socket_scm_helper
205 [failed, exit status 1] - output mismatch (see 205.out.bad)
home/eblake/qemu/tests/qemu-iotests/205.out.bad renamed from home/eblake/qemu/tests/qemu-iotests/205.out +34 -1
@@ -1,5 +1,159 @@ -....... +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to get "write" lock +Is another process using the image? +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to get "write" lock +Is another process using the image? +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to get "write" lock +Is another process using the image? +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to get "write" lock +Is another process using the image? +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to get "write" lock +Is another process using the image? +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to get "write" lock +Is another process using the image? +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to get "write" lock +Is another process using the image? +EEEEEEE +====================================================================== +ERROR: test_connect_after_remove_default (__main__.TestNbdServerRemove) +---------------------------------------------------------------------- +Traceback (most recent call last): + File "205", line 37, in setUp + self.vm.launch() + File "/home/eblake/qemu/tests/qemu-iotests/../../scripts/qemu.py", line 221, in launch + self._launch() + File "/home/eblake/qemu/tests/qemu-iotests/../../scripts/qemu.py", line 244, in _launch + self._post_launch() + File "/home/eblake/qemu/tests/qemu-iotests/../../scripts/qtest.py", line 100, in _post_launch + super(QEMUQtestMachine, self)._post_launch() + File "/home/eblake/qemu/tests/qemu-iotests/../../scripts/qemu.py", line 196, in _post_launch + self._qmp.accept() + File "/home/eblake/qemu/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 157, in accept + return self.__negotiate_capabilities() + File "/home/eblake/qemu/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 73, in __negotiate_capabilities + raise QMPConnectError +QMPConnectError
...
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 38 lines · Eric Blake
Quoted 5 lines · Eric Blake
Quoted 4 lines · Daniel P. Berrangé
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Support default luks options in VM.add_drive and in new library function
qemu_img_create. Use it in 205 iotests.Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>---
Reviewed-by Daniel P. Berrange <[email protected]>Thanks. I'll take this through my NBD queue.
git
git://repo.or.cz/qemu/ericb.gitnbdI'm seeing this failure now :(
$ ./check -luks 205 QEMU -- "/home/eblake/qemu/x86_64-softmmu/qemu-system-x86_64" -nodefaults -machine accel=qtest QEMU_IMG -- "/home/eblake/qemu/qemu-img" QEMU_IO -- "/home/eblake/qemu/qemu-io" --cache writeback QEMU_NBD -- "/home/eblake/qemu/qemu-nbd" IMGFMT -- luks (iter-time=10) IMGPROTO -- file PLATFORM -- Linux/x86_64 red 4.14.16-300.fc27.x86_64 TEST_DIR -- /home/eblake/qemu/tests/qemu-iotests/scratch SOCKET_SCM_HELPER -- /home/eblake/qemu/tests/qemu-iotests/socket_scm_helper205 [failed, exit status 1] - output mismatch (see 205.out.bad) --- /home/eblake/qemu/tests/qemu-iotests/205.out 2018-02-07 09:48:13.346107367 -0600
+++ /home/eblake/qemu/tests/qemu-iotests/205.out.bad 2018-02-07 14:35:21.859890826 -0600(quoted diff) +1
-1@@ -1,5 +1,159 @@ -....... +qemu-img: /home/eblake/qemu/tests/qemu-iotests/scratch/disk: Failed to
Quoted 2 lines
get "write" lock
+Is another process using the image?
Perhaps a false alarm due to a stale qemu-system-x86 process left over from an earlier aborted test run. When I retried on a fresh system, the test passed for me.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org