[libvirt] [tck PATCH v2 13/13] lib: allow marking the scratch disk as shareable

Daniel P. Berrangé posted 13 patches 6 years, 11 months ago
[libvirt] [tck PATCH v2 13/13] lib: allow marking the scratch disk as shareable
Posted by Daniel P. Berrangé 6 years, 11 months ago
One of the tests checks the ability to boot multiple guests at once, and
it is using the same (empty) disk image for all. Modern QEMU rejects
this sharing, but it is harmless in context of this test case, so we
mark the disk as shareable to allow it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 lib/Sys/Virt/TCK.pm                   | 6 +++++-
 lib/Sys/Virt/TCK/DomainBuilder.pm     | 3 +++
 scripts/domain/081-unique-id-create.t | 4 ++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index e7ff71b..ac9c125 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -782,6 +782,7 @@ sub generic_machine_domain {
     my $caps = exists $params{caps} ? $params{caps} : die "caps parameter is required";
     my $ostype = exists $params{ostype} ? $params{ostype} : "hvm";
     my $fullos = exists $params{fullos} ? $params{fullos} : 0;
+    my $shareddisk = exists $params{shareddisk} ? $params{shareddisk} : 0;
     my $filterref = exists $params{filterref} ? $params{filterref} : undef;
     my %filterparams = exists $params{filterparams} ? %{$params{filterparams}} : ();
 
@@ -857,7 +858,8 @@ sub generic_machine_domain {
 
         $b->disk(src => $config{root},
                  dst => $config{dev},
-                 type => "file");
+                 type => "file",
+                 shareable => $shareddisk);
         return $b;
     }
 }
@@ -915,6 +917,7 @@ sub generic_domain {
     my $ostype = exists $params{ostype} ? $params{ostype} : "hvm";
     my $fullos = exists $params{fullos} ? $params{fullos} : 0;
     my $netmode = exists $params{netmode} ? $params{netmode} : undef;
+    my $shareddisk = exists $params{shareddisk} ? $params{shareddisk} : 0;
     my $filterref = exists $params{filterref} ? $params{filterref} : undef;
     my %filterparams = exists $params{filterparams} ? %{$params{filterparams}} : ();
 
@@ -936,6 +939,7 @@ sub generic_domain {
         $b = $self->generic_machine_domain(name => $name,
                                            caps => $caps,
                                            ostype => $ostype,
+					   shareddisk => $shareddisk,
                                            fullos => $fullos,
                                            filterref => $filterref,
                                            filterparams => \%filterparams);
diff --git a/lib/Sys/Virt/TCK/DomainBuilder.pm b/lib/Sys/Virt/TCK/DomainBuilder.pm
index b6adbd3..5ca2a07 100644
--- a/lib/Sys/Virt/TCK/DomainBuilder.pm
+++ b/lib/Sys/Virt/TCK/DomainBuilder.pm
@@ -409,6 +409,9 @@ sub as_xml {
             $w->emptyTag("source",
                          file => $disk->{src});
         }
+        if ($disk->{shareable}) {
+            $w->emptyTag("shareable");
+        }
         $w->emptyTag("target",
                      dev => $disk->{dst},
                      $disk->{bus} ? (bus => $disk->{bus}) : ());
diff --git a/scripts/domain/081-unique-id-create.t b/scripts/domain/081-unique-id-create.t
index 07143a5..0d53599 100644
--- a/scripts/domain/081-unique-id-create.t
+++ b/scripts/domain/081-unique-id-create.t
@@ -54,13 +54,13 @@ my $uuid1 = "11111111-1111-1111-1111-111111111111";
 my $uuid2 = "22222222-1111-1111-1111-111111111111";
 
 # The initial config
-my $xml = $tck->generic_domain(name => $name1)->uuid($uuid1)->as_xml;
+my $xml = $tck->generic_domain(name => $name1, shareddisk => 1)->uuid($uuid1)->as_xml;
 # One with a different UUID, matching name
 my $xml_diffuuid = $tck->generic_domain(name => $name1)->uuid($uuid2)->as_xml;
 # One with a matching UUID, different name
 my $xml_diffname = $tck->generic_domain(name => $name2)->uuid($uuid1)->as_xml;
 # One with a different UUID, different name
-my $xml_diffboth = $tck->generic_domain(name => $name2)->uuid($uuid2)->as_xml;
+my $xml_diffboth = $tck->generic_domain(name => $name2, shareddisk => 1)->uuid($uuid2)->as_xml;
 
 diag "Defining persistent domain config";
 my ($dom, $dom1);
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [tck PATCH v2 13/13] lib: allow marking the scratch disk as shareable
Posted by Laine Stump 6 years, 11 months ago
On 05/21/2018 12:46 PM, Daniel P. Berrangé wrote:
> One of the tests checks the ability to boot multiple guests at once, and
> it is using the same (empty) disk image for all. Modern QEMU rejects
> this sharing, but it is harmless in context of this test case, so we
> mark the disk as shareable to allow it.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

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

> ---
>  lib/Sys/Virt/TCK.pm                   | 6 +++++-
>  lib/Sys/Virt/TCK/DomainBuilder.pm     | 3 +++
>  scripts/domain/081-unique-id-create.t | 4 ++--
>  3 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
> index e7ff71b..ac9c125 100644
> --- a/lib/Sys/Virt/TCK.pm
> +++ b/lib/Sys/Virt/TCK.pm
> @@ -782,6 +782,7 @@ sub generic_machine_domain {
>      my $caps = exists $params{caps} ? $params{caps} : die "caps parameter is required";
>      my $ostype = exists $params{ostype} ? $params{ostype} : "hvm";
>      my $fullos = exists $params{fullos} ? $params{fullos} : 0;
> +    my $shareddisk = exists $params{shareddisk} ? $params{shareddisk} : 0;
>      my $filterref = exists $params{filterref} ? $params{filterref} : undef;
>      my %filterparams = exists $params{filterparams} ? %{$params{filterparams}} : ();
>  
> @@ -857,7 +858,8 @@ sub generic_machine_domain {
>  
>          $b->disk(src => $config{root},
>                   dst => $config{dev},
> -                 type => "file");
> +                 type => "file",
> +                 shareable => $shareddisk);
>          return $b;
>      }
>  }
> @@ -915,6 +917,7 @@ sub generic_domain {
>      my $ostype = exists $params{ostype} ? $params{ostype} : "hvm";
>      my $fullos = exists $params{fullos} ? $params{fullos} : 0;
>      my $netmode = exists $params{netmode} ? $params{netmode} : undef;
> +    my $shareddisk = exists $params{shareddisk} ? $params{shareddisk} : 0;
>      my $filterref = exists $params{filterref} ? $params{filterref} : undef;
>      my %filterparams = exists $params{filterparams} ? %{$params{filterparams}} : ();
>  
> @@ -936,6 +939,7 @@ sub generic_domain {
>          $b = $self->generic_machine_domain(name => $name,
>                                             caps => $caps,
>                                             ostype => $ostype,
> +					   shareddisk => $shareddisk,
>                                             fullos => $fullos,
>                                             filterref => $filterref,
>                                             filterparams => \%filterparams);
> diff --git a/lib/Sys/Virt/TCK/DomainBuilder.pm b/lib/Sys/Virt/TCK/DomainBuilder.pm
> index b6adbd3..5ca2a07 100644
> --- a/lib/Sys/Virt/TCK/DomainBuilder.pm
> +++ b/lib/Sys/Virt/TCK/DomainBuilder.pm
> @@ -409,6 +409,9 @@ sub as_xml {
>              $w->emptyTag("source",
>                           file => $disk->{src});
>          }
> +        if ($disk->{shareable}) {
> +            $w->emptyTag("shareable");
> +        }
>          $w->emptyTag("target",
>                       dev => $disk->{dst},
>                       $disk->{bus} ? (bus => $disk->{bus}) : ());
> diff --git a/scripts/domain/081-unique-id-create.t b/scripts/domain/081-unique-id-create.t
> index 07143a5..0d53599 100644
> --- a/scripts/domain/081-unique-id-create.t
> +++ b/scripts/domain/081-unique-id-create.t
> @@ -54,13 +54,13 @@ my $uuid1 = "11111111-1111-1111-1111-111111111111";
>  my $uuid2 = "22222222-1111-1111-1111-111111111111";
>  
>  # The initial config
> -my $xml = $tck->generic_domain(name => $name1)->uuid($uuid1)->as_xml;
> +my $xml = $tck->generic_domain(name => $name1, shareddisk => 1)->uuid($uuid1)->as_xml;
>  # One with a different UUID, matching name
>  my $xml_diffuuid = $tck->generic_domain(name => $name1)->uuid($uuid2)->as_xml;
>  # One with a matching UUID, different name
>  my $xml_diffname = $tck->generic_domain(name => $name2)->uuid($uuid1)->as_xml;
>  # One with a different UUID, different name
> -my $xml_diffboth = $tck->generic_domain(name => $name2)->uuid($uuid2)->as_xml;
> +my $xml_diffboth = $tck->generic_domain(name => $name2, shareddisk => 1)->uuid($uuid2)->as_xml;
>  
>  diag "Defining persistent domain config";
>  my ($dom, $dom1);


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list