[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 05/19] iotests.py: Add (verify|has)_working_luks()
From: |
Max Reitz |
Subject: |
Re: [PATCH 05/19] iotests.py: Add (verify|has)_working_luks() |
Date: |
Tue, 30 Jun 2020 10:52:37 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 29.06.20 12:12, Maxim Levitsky wrote:
> On Thu, 2020-06-25 at 14:55 +0200, Max Reitz wrote:
>> Similar to _require_working_luks for bash tests, these functions can be
>> used to check whether our luks driver can actually create images.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> tests/qemu-iotests/iotests.py | 39 +++++++++++++++++++++++++++++++++++
>> 1 file changed, 39 insertions(+)
>>
>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
>> index eee94e18cc..039170a8a3 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -1052,6 +1052,45 @@ def verify_quorum():
>> if not supports_quorum():
>> notrun('quorum support missing')
>>
>> +def has_working_luks() -> Tuple[bool, str]:
>> + """
>> + Check whether our LUKS driver can actually create images
>> + (this extends to LUKS encryption for qcow2).
>> +
>> + If not, return the reason why.
>> + """
>> +
>> + img_file = f'{test_dir}/luks-test.luks'
>> + (output, status) = \
>> + qemu_img_pipe_and_status('create', '-f', 'luks',
>> + '--object', luks_default_secret_object,
>> + '-o', luks_default_key_secret_opt,
>> + '-o', 'iter-time=10',
>> + img_file, '1G')
>> + try:
>> + os.remove(img_file)
>> + except OSError:
>> + pass
>> +
>> + if status != 0:
>> + reason = output
>> + for line in output.splitlines():
>> + if img_file + ':' in line:
>> + reason = line.split(img_file + ':', 1)[1].strip()
>> + break
>> +
>> + return (False, reason)
>> + else:
>> + return (True, '')
>> +
>> +def verify_working_luks():
>> + """
>> + Skip test suite if LUKS does not work
>> + """
>> + (working, reason) = has_working_luks()
>> + if not working:
>> + notrun(reason)
>> +
>> def qemu_pipe(*args):
>> """
>> Run qemu with an option to print something and exit (e.g. a help
>> option).
>
> It just occured to me that we can have a situation when luks driver is
> blacklisted
> (via block driver blacklist "--block-drv-whitelist=") then this test.
>
> THe whilelist only affects the qmp it seems so this check doesn't catch it,
> plus you could have case when luks driver is blacklisted but qcow2 isn't
Yes, the whitelist only affects qemu proper, not qemu-img.
> When I build qemu with
> '--block-drv-whitelist='raw,qcow2' I was able to break iotests 295 296
> But this is such a non issue, that I am just noting for reference.
Hm. If anything, that’s actually a problem in the test infrastructure,
isn’t it? For example, if you don’t whitelist qcow2, then all qcow2
tests break. Ideally, they shouldn’t. The test infrastructure should
check whether the format used to run the test ($IMGFMT) is actually
supported (e.g. iotests.py’s _verify_image_format() could check whether
the format is actually in supported_formats()), and if it isn’t, skip
the test.
OTOH, that’s pretty much the user’s fault for using an $IMGFMT that they
didn’t whitelist, so I’m not sure whether we’re actually keen on fixing
that.
*shrug* O:)
Max
signature.asc
Description: OpenPGP digital signature
- [PATCH 00/19] block: LUKS encryption slot management + iotest tweaks, Max Reitz, 2020/06/25
- [PATCH 02/19] iotests: filter few more luks specific create options, Max Reitz, 2020/06/25
- [PATCH 01/19] iotests: Make _filter_img_create more active, Max Reitz, 2020/06/25
- [PATCH 03/19] iotests/common.rc: Add _require_working_luks, Max Reitz, 2020/06/25
- [PATCH 05/19] iotests.py: Add (verify|has)_working_luks(), Max Reitz, 2020/06/25
- [PATCH 04/19] iotests.py: Add qemu_img_pipe_and_status(), Max Reitz, 2020/06/25
- [PATCH 06/19] iotests: Check whether luks works, Max Reitz, 2020/06/25
- [PATCH 07/19] qcrypto/core: add generic infrastructure for crypto options amendment, Max Reitz, 2020/06/25
- [PATCH 08/19] qcrypto/luks: implement encryption key management, Max Reitz, 2020/06/25
- [PATCH 09/19] block/amend: add 'force' option, Max Reitz, 2020/06/25
- [PATCH 10/19] block/amend: separate amend and create options for qemu-img, Max Reitz, 2020/06/25
- [PATCH 12/19] block/crypto: rename two functions, Max Reitz, 2020/06/25