qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 05/19] iotests.py: Add (verify|has)_working_luks()
Date: Mon, 29 Jun 2020 13:12:18 +0300	[thread overview]
Message-ID: <64a986ceccb48c45aaf9910c9a0ab865916b6fa6.camel@redhat.com> (raw)
In-Reply-To: <20200625125548.870061-6-mreitz@redhat.com>

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

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.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>


Best regards,
	Maxim Levitsky






  reply	other threads:[~2020-06-29 10:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 12:55 [PATCH 00/19] block: LUKS encryption slot management + iotest tweaks Max Reitz
2020-06-25 12:55 ` [PATCH 01/19] iotests: Make _filter_img_create more active Max Reitz
2020-06-28 15:12   ` Maxim Levitsky
2020-06-25 12:55 ` [PATCH 02/19] iotests: filter few more luks specific create options Max Reitz
2020-06-25 12:55 ` [PATCH 03/19] iotests/common.rc: Add _require_working_luks Max Reitz
2020-06-28 19:02   ` Maxim Levitsky
2020-06-25 12:55 ` [PATCH 04/19] iotests.py: Add qemu_img_pipe_and_status() Max Reitz
2020-06-29  8:45   ` Maxim Levitsky
2020-06-25 12:55 ` [PATCH 05/19] iotests.py: Add (verify|has)_working_luks() Max Reitz
2020-06-29 10:12   ` Maxim Levitsky [this message]
2020-06-30  8:52     ` Max Reitz
2020-06-25 12:55 ` [PATCH 06/19] iotests: Check whether luks works Max Reitz
2020-06-29 12:03   ` Maxim Levitsky
2020-06-30  8:53     ` Max Reitz
2020-06-25 12:55 ` [PATCH 07/19] qcrypto/core: add generic infrastructure for crypto options amendment Max Reitz
2020-06-25 12:55 ` [PATCH 08/19] qcrypto/luks: implement encryption key management Max Reitz
2020-06-25 12:55 ` [PATCH 09/19] block/amend: add 'force' option Max Reitz
2020-06-25 12:55 ` [PATCH 10/19] block/amend: separate amend and create options for qemu-img Max Reitz
2020-06-25 12:55 ` [PATCH 11/19] block/amend: refactor qcow2 amend options Max Reitz
2020-06-25 12:55 ` [PATCH 12/19] block/crypto: rename two functions Max Reitz
2020-06-25 12:55 ` [PATCH 13/19] block/crypto: implement the encryption key management Max Reitz
2020-06-25 12:55 ` [PATCH 14/19] block/qcow2: extend qemu-img amend interface with crypto options Max Reitz
2020-06-25 12:55 ` [PATCH 15/19] iotests: qemu-img tests for luks key management Max Reitz
2020-06-29 12:05   ` Maxim Levitsky
2020-06-30  8:56     ` Max Reitz
2020-06-30  9:23       ` Maxim Levitsky
2020-06-25 12:55 ` [PATCH 16/19] block/core: add generic infrastructure for x-blockdev-amend qmp command Max Reitz
2020-06-25 12:55 ` [PATCH 17/19] block/crypto: implement blockdev-amend Max Reitz
2020-06-25 12:55 ` [PATCH 18/19] block/qcow2: " Max Reitz
2020-06-25 12:55 ` [PATCH 19/19] iotests: add tests for blockdev-amend Max Reitz
2020-06-29 12:06   ` Maxim Levitsky
2020-06-25 13:22 ` [PATCH 00/19] block: LUKS encryption slot management + iotest tweaks no-reply
2020-07-03 11:57 ` Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64a986ceccb48c45aaf9910c9a0ab865916b6fa6.camel@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).