Remove the encrypt.format option from the two blockdev-add test cases for encrypted qcow2 images in 087 to explicitly test that this parameter is now optional.
Additionally, show that explicitly specifying encrypt.format=auto works just as well, the same for specifying the correct format (encrypt.format=luks here), and that specifying the wrong format (encrypt.format=aes) results in an error. While touching this test case, reduce the LUKS iteration time to 10 so the test stays reasonably fast. Signed-off-by: Max Reitz <mre...@redhat.com> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> Reviewed-by: Eric Blake <ebl...@redhat.com> --- tests/qemu-iotests/087 | 65 +++++++++++++++++++++++--------------- tests/qemu-iotests/087.out | 26 ++++++++++++++- 2 files changed, 64 insertions(+), 27 deletions(-) diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index d6c8613419..0e52dec483 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -149,7 +149,6 @@ run_qemu <<EOF "filename": "$TEST_IMG" }, "encrypt": { - "format": "aes", "key-secret": "sec0" } } @@ -161,34 +160,48 @@ echo echo === Encrypted image LUKS === echo -_make_test_img --object secret,id=sec0,data=123456 -o encrypt.format=luks,encrypt.key-secret=sec0 $size -run_qemu <<EOF -{ "execute": "qmp_capabilities" } -{ "execute": "object-add", - "arguments": { - "qom-type": "secret", - "id": "sec0", - "props": { - "data": "123456" - } - } -} -{ "execute": "blockdev-add", - "arguments": { - "driver": "$IMGFMT", - "node-name": "disk", - "file": { - "driver": "file", - "filename": "$TEST_IMG" - }, - "encrypt": { - "format": "luks", - "key-secret": "sec0" +_make_test_img \ + --object secret,id=sec0,data=123456 \ + -o encrypt.format=luks,encrypt.key-secret=sec0,encrypt.iter-time=10 \ + $size + +# Adds the qcow2+LUKS image via blockdev-add. +# First parameter: Optional entry for the 'encrypt' option dict +function luks_test() +{ + run_qemu <<EOF + { "execute": "qmp_capabilities" } + { "execute": "object-add", + "arguments": { + "qom-type": "secret", + "id": "sec0", + "props": { + "data": "123456" + } } } - } -{ "execute": "quit" } + { "execute": "blockdev-add", + "arguments": { + "driver": "$IMGFMT", + "node-name": "disk", + "file": { + "driver": "file", + "filename": "$TEST_IMG" + }, + "encrypt": { + $1 + "key-secret": "sec0" + } + } + } + { "execute": "quit" } EOF +} + +luks_test '' # Implicit encrypt.format=auto +luks_test '"format": "auto",' # Explicit encrypt.format=auto +luks_test '"format": "luks",' # Explicit encrypt.format=luks +luks_test '"format": "aes",' # Explicit encrypt.format=aes (wrong) echo echo === Missing driver === diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out index 2d92ea847b..6c1d83519b 100644 --- a/tests/qemu-iotests/087.out +++ b/tests/qemu-iotests/087.out @@ -46,7 +46,7 @@ QMP_VERSION === Encrypted image LUKS === -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encrypt.format=luks encrypt.key-secret=sec0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encrypt.format=luks encrypt.key-secret=sec0 encrypt.iter-time=10 Testing: QMP_VERSION {"return": {}} @@ -55,6 +55,30 @@ QMP_VERSION {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} + +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"return": {}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} + +Testing: +QMP_VERSION +{"return": {}} +{"return": {}} +{"error": {"class": "GenericError", "desc": "Header reported 'luks' encryption format but options specify 'aes'"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} + === Missing driver === -- 2.21.0