[libvirt] [tck PATCH v2 07/13] scripts: switch to using luks encryption with QEMU

Laine Stump laine at laine.org
Sat Jun 2 01:06:31 UTC 2018


On 05/21/2018 12:46 PM, Daniel P. Berrangé wrote:
> The ability to use qcow legacy encryption is disabled with QEMU for a
> long time. Switch to using luks encryption, although this is not yet
> fully wired up in libvirt so the tests still (temporarily) fail.
>
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>

Reviewed-by: Laine Stump <laine at laine.org>

(when applied together with patch 08/13, of course :-)

> ---
>  lib/Sys/Virt/TCK/DomainBuilder.pm     |  4 ++--
>  lib/Sys/Virt/TCK/StorageVolBuilder.pm | 18 +++++++++++++-----
>  scripts/qemu/100-disk-encryption.t    |  2 ++
>  3 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/lib/Sys/Virt/TCK/DomainBuilder.pm b/lib/Sys/Virt/TCK/DomainBuilder.pm
> index 83cea15..b6adbd3 100644
> --- a/lib/Sys/Virt/TCK/DomainBuilder.pm
> +++ b/lib/Sys/Virt/TCK/DomainBuilder.pm
> @@ -412,8 +412,8 @@ sub as_xml {
>          $w->emptyTag("target",
>                       dev => $disk->{dst},
>                       $disk->{bus} ? (bus => $disk->{bus}) : ());
> -        if ($disk->{secret}) {
> -            $w->startTag("encryption", format => "qcow");
> +        if ($disk->{encformat}) {
> +            $w->startTag("encryption", format => $self->{encryption_format});
>              $w->emptyTag("secret", type => "passphrase", uuid => $disk->{secret});
>              $w->endTag("encryption");
>          }
> diff --git a/lib/Sys/Virt/TCK/StorageVolBuilder.pm b/lib/Sys/Virt/TCK/StorageVolBuilder.pm
> index 7208f75..ad950ed 100644
> --- a/lib/Sys/Virt/TCK/StorageVolBuilder.pm
> +++ b/lib/Sys/Virt/TCK/StorageVolBuilder.pm
> @@ -60,6 +60,14 @@ sub format {
>      return $self;
>  }
>  
> +sub encryption_format {
> +    my $self = shift;
> +
> +    $self->{encformat} = shift;
> +
> +    return $self;
> +}
> +
>  sub secret {
>      my $self = shift;
>  
> @@ -95,13 +103,13 @@ sub as_xml {
>      $w->dataElement("capacity", $self->{capacity});
>      $w->dataElement("allocation", $self->{allocation});
>  
> -    if ($self->{format} || $self->{secret}) {
> +    if ($self->{format} || $self->{encformat}) {
>          $w->startTag("target");
>          if ($self->{format}) {
>              $w->emptyTag("format", type => $self->{format});
>          }
> -        if ($self->{secret}) {
> -            $w->startTag("encryption", format => "qcow");
> +        if ($self->{encformat}) {
> +            $w->startTag("encryption", format => $self->{encformat});
>              $w->emptyTag("secret", type => "passphrase", uuid => $self->{secret});
>              $w->endTag("encryption");
>          }
> @@ -114,8 +122,8 @@ sub as_xml {
>          if ($self->{backingFormat}) {
>              $w->emptyTag("format", type => $self->{backingFormat});
>          }
> -        if ($self->{secret}) {
> -            $w->startTag("encryption", format => "qcow");
> +        if ($self->{encformat}) {
> +            $w->startTag("encryption", format => $self->{encformat});
>              $w->emptyTag("secret", type => "passphrase", uuid => $self->{secret});
>              $w->endTag("encryption");
>          }
> diff --git a/scripts/qemu/100-disk-encryption.t b/scripts/qemu/100-disk-encryption.t
> index 8a0fd5e..3b1651a 100644
> --- a/scripts/qemu/100-disk-encryption.t
> +++ b/scripts/qemu/100-disk-encryption.t
> @@ -76,6 +76,7 @@ lives_ok(sub { $pool = $conn->create_storage_pool($poolXML) }, "pool created");
>  my $volXML = Sys::Virt::TCK::StorageVolBuilder->new(name => "demo.qcow2")
>      ->capacity(1024*1024*1024)
>      ->format("qcow2")
> +    ->encryption_format("luks")
>      ->secret($secretUUID)
>      ->as_xml();
>  
> @@ -86,6 +87,7 @@ lives_ok(sub { $vol = $pool->create_volume($volXML) }, "volume created");
>  
>  my $xml = $tck->generic_domain(name => "tck")
>      ->disk(format => { name => "qemu", type => "qcow2" },
> +	   encryption_format => "luks",
>  	   secret => $secretUUID,
>  	   type => "file",
>  	   src => $disk,





More information about the libvir-list mailing list