[libvirt] [tck PATCH v2 0/5] Fix libvirt-tck nwfilter tests

I've pushed the patches that passed review. These patches split a single patch from V1 into 2 patches, repost one patch that had no response, calls out a single line that had sneaked into one of the ACKed patches, and remove all tabs from perl and sh scripts. Laine Stump (5): parameterize filterref in generic_domain default to no nwfilter in test domains filter for proper IP address in tcpdump looking for broadcast packet kill dhclient before attempting to change guest IP in no-ip-spoofing test untabify all perl and sh files lib/Sys/Virt/TCK.pm | 549 ++++++++++++----------- lib/Sys/Virt/TCK/Capabilities.pm | 84 ++-- lib/Sys/Virt/TCK/DomainBuilder.pm | 312 ++++++------- lib/Sys/Virt/TCK/NetworkBuilder.pm | 44 +- lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 +- lib/Sys/Virt/TCK/SELinux.pm | 6 +- lib/Sys/Virt/TCK/StoragePoolBuilder.pm | 40 +- lib/Sys/Virt/TCK/StorageVolBuilder.pm | 48 +- lib/Sys/Virt/TCK/TAP/XMLFormatter.pm | 18 +- lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm | 66 +-- scripts/nwfilter/100-ping-still-working.t | 3 +- scripts/nwfilter/210-no-mac-spoofing.t | 3 +- scripts/nwfilter/220-no-ip-spoofing.t | 4 +- scripts/nwfilter/230-no-mac-broadcast.t | 5 +- scripts/nwfilter/240-no-arp-spoofing.t | 3 +- scripts/nwfilter/300-vsitype.t | 2 +- scripts/nwfilter/concurrency/chg-vm-filter.sh | 18 +- scripts/nwfilter/concurrency/start-destroy-vm.sh | 20 +- scripts/nwfilter/nwfilter2vmtest.sh | 42 +- 19 files changed, 641 insertions(+), 632 deletions(-) -- 2.14.3

The default filterref is still clean-traffic, but we can now set it to "no-broadcast-mac" for the test by that same name. This corrects a problem with the no-mac-broadcast test, which was checking to see that packets with a destination MAC address of ff:ff:ff:ff:ff:ff weren't allowed, but was neglecting to add the "no-mac-broadcast" nwfilter to the domain (the test was erroneously succeeding because it was checking for a different type of packet than it was generating, which is fixed in a separate patch). Signed-off-by: Laine Stump <laine@laine.org> --- Change from V1: keep default filter of "clean-traffic" rather than no filter. lib/Sys/Virt/TCK.pm | 9 ++++++--- scripts/nwfilter/230-no-mac-broadcast.t | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index ce8e81b..01ce3ea 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -766,6 +766,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; if ($fullos) { my %config = $self->get_image($caps, $ostype); @@ -792,7 +793,7 @@ sub generic_machine_domain { source => "default", model => "virtio", mac => "52:54:00:11:11:11", - filterref => "clean-traffic"); + filterref => $filterref); my $xml = $b->as_xml(); # Cleanup the temporary interface $b->rminterface(); @@ -896,6 +897,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities); @@ -915,7 +917,8 @@ sub generic_domain { $b = $self->generic_machine_domain(name => $name, caps => $caps, ostype => $ostype, - fullos => $fullos); + fullos => $fullos, + filterref => $filterref); } if ($netmode) { if ($netmode eq "vepa") { @@ -931,7 +934,7 @@ sub generic_domain { source => "default", model => "virtio", mac => "52:54:00:11:11:11", - filterref => "clean-traffic"); + filterref => $filterref); } } return $b; diff --git a/scripts/nwfilter/230-no-mac-broadcast.t b/scripts/nwfilter/230-no-mac-broadcast.t index ed6932c..6ab20d8 100644 --- a/scripts/nwfilter/230-no-mac-broadcast.t +++ b/scripts/nwfilter/230-no-mac-broadcast.t @@ -43,7 +43,8 @@ END { # create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "no-mac-broadcast")->as_xml(); my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); -- 2.14.3

On 02/08/2018 02:19 PM, Laine Stump wrote:
The default filterref is still clean-traffic, but we can now set it to "no-broadcast-mac" for the test by that same name.
This corrects a problem with the no-mac-broadcast test, which was checking to see that packets with a destination MAC address of ff:ff:ff:ff:ff:ff weren't allowed, but was neglecting to add the "no-mac-broadcast" nwfilter to the domain (the test was erroneously succeeding because it was checking for a different type of packet than it was generating, which is fixed in a separate patch).
Signed-off-by: Laine Stump <laine@laine.org> ---
Change from V1: keep default filter of "clean-traffic" rather than no filter.
lib/Sys/Virt/TCK.pm | 9 ++++++--- scripts/nwfilter/230-no-mac-broadcast.t | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index ce8e81b..01ce3ea 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -766,6 +766,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic";
if ($fullos) { my %config = $self->get_image($caps, $ostype); @@ -792,7 +793,7 @@ sub generic_machine_domain { source => "default", model => "virtio", mac => "52:54:00:11:11:11", - filterref => "clean-traffic"); + filterref => $filterref); my $xml = $b->as_xml(); # Cleanup the temporary interface $b->rminterface(); @@ -896,6 +897,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic";
my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities);
@@ -915,7 +917,8 @@ sub generic_domain { $b = $self->generic_machine_domain(name => $name, caps => $caps, ostype => $ostype, - fullos => $fullos); + fullos => $fullos, + filterref => $filterref); } if ($netmode) { if ($netmode eq "vepa") { @@ -931,7 +934,7 @@ sub generic_domain { source => "default", model => "virtio", mac => "52:54:00:11:11:11", - filterref => "clean-traffic"); + filterref => $filterref); } } return $b; diff --git a/scripts/nwfilter/230-no-mac-broadcast.t b/scripts/nwfilter/230-no-mac-broadcast.t index ed6932c..6ab20d8 100644 --- a/scripts/nwfilter/230-no-mac-broadcast.t +++ b/scripts/nwfilter/230-no-mac-broadcast.t @@ -43,7 +43,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "no-mac-broadcast")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object");
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

On Thu, Feb 08, 2018 at 02:19:35PM -0500, Laine Stump wrote:
The default filterref is still clean-traffic, but we can now set it to "no-broadcast-mac" for the test by that same name.
This corrects a problem with the no-mac-broadcast test, which was checking to see that packets with a destination MAC address of ff:ff:ff:ff:ff:ff weren't allowed, but was neglecting to add the "no-mac-broadcast" nwfilter to the domain (the test was erroneously succeeding because it was checking for a different type of packet than it was generating, which is fixed in a separate patch).
Signed-off-by: Laine Stump <laine@laine.org> ---
Change from V1: keep default filter of "clean-traffic" rather than no filter.
lib/Sys/Virt/TCK.pm | 9 ++++++--- scripts/nwfilter/230-no-mac-broadcast.t | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

When the nwfilter tests were added, the config for *all* test domains was changed to apply the "clean-traffic" filter. This doesn't have an ill effect on any test that I know of, but if nwfilter code happened to be broken in just the right way, other tests that might be unrelated could fail as well. This patch changes the default nwfilter from "clean-traffic" to nothing, and explicitly sets clean-traffic for those tests that require it. Signed-off-by: Laine Stump <laine@laine.org> --- New in V2. This was formerly a part of the previous patch. lib/Sys/Virt/TCK.pm | 4 ++-- scripts/nwfilter/100-ping-still-working.t | 3 ++- scripts/nwfilter/210-no-mac-spoofing.t | 3 ++- scripts/nwfilter/220-no-ip-spoofing.t | 3 ++- scripts/nwfilter/240-no-arp-spoofing.t | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index 01ce3ea..2259042 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -766,7 +766,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; + my $filterref = exists $params{filterref} ? $params{filterref} : undef; if ($fullos) { my %config = $self->get_image($caps, $ostype); @@ -897,7 +897,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; + my $filterref = exists $params{filterref} ? $params{filterref} : undef; my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities); diff --git a/scripts/nwfilter/100-ping-still-working.t b/scripts/nwfilter/100-ping-still-working.t index 5afc6a6..1bbd7c5 100644 --- a/scripts/nwfilter/100-ping-still-working.t +++ b/scripts/nwfilter/100-ping-still-working.t @@ -44,7 +44,8 @@ END { # create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml(); my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/210-no-mac-spoofing.t b/scripts/nwfilter/210-no-mac-spoofing.t index 63adf5c..3438f4a 100644 --- a/scripts/nwfilter/210-no-mac-spoofing.t +++ b/scripts/nwfilter/210-no-mac-spoofing.t @@ -44,7 +44,8 @@ END { # create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml(); my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/220-no-ip-spoofing.t b/scripts/nwfilter/220-no-ip-spoofing.t index 6e390ef..72dcae8 100644 --- a/scripts/nwfilter/220-no-ip-spoofing.t +++ b/scripts/nwfilter/220-no-ip-spoofing.t @@ -44,7 +44,8 @@ END { # create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml(); my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/240-no-arp-spoofing.t b/scripts/nwfilter/240-no-arp-spoofing.t index a7ba9d2..dfc8e08 100644 --- a/scripts/nwfilter/240-no-arp-spoofing.t +++ b/scripts/nwfilter/240-no-arp-spoofing.t @@ -45,7 +45,8 @@ END { # create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml(); my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); -- 2.14.3

On 02/08/2018 02:19 PM, Laine Stump wrote:
When the nwfilter tests were added, the config for *all* test domains was changed to apply the "clean-traffic" filter. This doesn't have an ill effect on any test that I know of, but if nwfilter code happened to be broken in just the right way, other tests that might be unrelated could fail as well.
This patch changes the default nwfilter from "clean-traffic" to nothing, and explicitly sets clean-traffic for those tests that require it.
Signed-off-by: Laine Stump <laine@laine.org> ---
New in V2. This was formerly a part of the previous patch.
lib/Sys/Virt/TCK.pm | 4 ++-- scripts/nwfilter/100-ping-still-working.t | 3 ++- scripts/nwfilter/210-no-mac-spoofing.t | 3 ++- scripts/nwfilter/220-no-ip-spoofing.t | 3 ++- scripts/nwfilter/240-no-arp-spoofing.t | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index 01ce3ea..2259042 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -766,7 +766,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; + my $filterref = exists $params{filterref} ? $params{filterref} : undef;
if ($fullos) { my %config = $self->get_image($caps, $ostype); @@ -897,7 +897,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; + my $filterref = exists $params{filterref} ? $params{filterref} : undef;
my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities);
diff --git a/scripts/nwfilter/100-ping-still-working.t b/scripts/nwfilter/100-ping-still-working.t index 5afc6a6..1bbd7c5 100644 --- a/scripts/nwfilter/100-ping-still-working.t +++ b/scripts/nwfilter/100-ping-still-working.t @@ -44,7 +44,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/210-no-mac-spoofing.t b/scripts/nwfilter/210-no-mac-spoofing.t index 63adf5c..3438f4a 100644 --- a/scripts/nwfilter/210-no-mac-spoofing.t +++ b/scripts/nwfilter/210-no-mac-spoofing.t @@ -44,7 +44,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/220-no-ip-spoofing.t b/scripts/nwfilter/220-no-ip-spoofing.t index 6e390ef..72dcae8 100644 --- a/scripts/nwfilter/220-no-ip-spoofing.t +++ b/scripts/nwfilter/220-no-ip-spoofing.t @@ -44,7 +44,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/240-no-arp-spoofing.t b/scripts/nwfilter/240-no-arp-spoofing.t index a7ba9d2..dfc8e08 100644 --- a/scripts/nwfilter/240-no-arp-spoofing.t +++ b/scripts/nwfilter/240-no-arp-spoofing.t @@ -45,7 +45,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object");
All tests now have an explicit filter since 230-no-mac-broadcast.t got one in the previous patch. Review-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

On 02/08/2018 06:10 PM, Stefan Berger wrote:
On 02/08/2018 02:19 PM, Laine Stump wrote:
When the nwfilter tests were added, the config for *all* test domains was changed to apply the "clean-traffic" filter. This doesn't have an ill effect on any test that I know of, but if nwfilter code happened to be broken in just the right way, other tests that might be unrelated could fail as well.
This patch changes the default nwfilter from "clean-traffic" to nothing, and explicitly sets clean-traffic for those tests that require it.
Signed-off-by: Laine Stump <laine@laine.org> ---
New in V2. This was formerly a part of the previous patch.
lib/Sys/Virt/TCK.pm | 4 ++-- scripts/nwfilter/100-ping-still-working.t | 3 ++- scripts/nwfilter/210-no-mac-spoofing.t | 3 ++- scripts/nwfilter/220-no-ip-spoofing.t | 3 ++- scripts/nwfilter/240-no-arp-spoofing.t | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index 01ce3ea..2259042 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -766,7 +766,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; + my $filterref = exists $params{filterref} ? $params{filterref} : undef;
if ($fullos) { my %config = $self->get_image($caps, $ostype); @@ -897,7 +897,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 $filterref = exists $params{filterref} ? $params{filterref} : "clean-traffic"; + my $filterref = exists $params{filterref} ? $params{filterref} : undef;
my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities);
diff --git a/scripts/nwfilter/100-ping-still-working.t b/scripts/nwfilter/100-ping-still-working.t index 5afc6a6..1bbd7c5 100644 --- a/scripts/nwfilter/100-ping-still-working.t +++ b/scripts/nwfilter/100-ping-still-working.t @@ -44,7 +44,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/210-no-mac-spoofing.t b/scripts/nwfilter/210-no-mac-spoofing.t index 63adf5c..3438f4a 100644 --- a/scripts/nwfilter/210-no-mac-spoofing.t +++ b/scripts/nwfilter/210-no-mac-spoofing.t @@ -44,7 +44,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/220-no-ip-spoofing.t b/scripts/nwfilter/220-no-ip-spoofing.t index 6e390ef..72dcae8 100644 --- a/scripts/nwfilter/220-no-ip-spoofing.t +++ b/scripts/nwfilter/220-no-ip-spoofing.t @@ -44,7 +44,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/240-no-arp-spoofing.t b/scripts/nwfilter/240-no-arp-spoofing.t index a7ba9d2..dfc8e08 100644 --- a/scripts/nwfilter/240-no-arp-spoofing.t +++ b/scripts/nwfilter/240-no-arp-spoofing.t @@ -45,7 +45,8 @@ END {
# create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "network")->as_xml(); + netmode => "network", + filterref => "clean-traffic")->as_xml();
my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object");
All tests now have an explicit filter since 230-no-mac-broadcast.t got one in the previous patch.
Review-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This is to say: Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

On 02/08/2018 06:10 PM, Stefan Berger wrote:
All tests now have an explicit filter since 230-no-mac-broadcast.t got one in the previous patch.
All the *nwfilter* tests now have an explicit filter. There are also several tests in the domain, qemu, and selinux directories (and one in hooks) that use generic_domain.

On Thu, Feb 08, 2018 at 02:19:36PM -0500, Laine Stump wrote:
When the nwfilter tests were added, the config for *all* test domains was changed to apply the "clean-traffic" filter. This doesn't have an ill effect on any test that I know of, but if nwfilter code happened to be broken in just the right way, other tests that might be unrelated could fail as well.
This patch changes the default nwfilter from "clean-traffic" to nothing, and explicitly sets clean-traffic for those tests that require it.
Signed-off-by: Laine Stump <laine@laine.org> ---
New in V2. This was formerly a part of the previous patch.
lib/Sys/Virt/TCK.pm | 4 ++-- scripts/nwfilter/100-ping-still-working.t | 3 ++- scripts/nwfilter/210-no-mac-spoofing.t | 3 ++- scripts/nwfilter/220-no-ip-spoofing.t | 3 ++- scripts/nwfilter/240-no-arp-spoofing.t | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

In the no-mac-broadcast test, a ping is sent to 192.168.122.255, but tcpdump is set to look for packets with a destination IP of 255.255.255.255. Change it to check for the correct IP address and also for mac broadcast (which is what the no-mac-broadcast filter actually looks at). This should eliminate the "false success" that was happening because tcpdump wasn't actually seeing the broadcast packet the guest was sending, as well as catching the "false failure" caused by tcpdump seeing other traffic from the guest unrelated to the test (which happened to be broadcasts sent to 255.255.255.255). Signed-off-by: Laine Stump <laine@laine.org> --- Unchanged from V1, it just had no review. scripts/nwfilter/230-no-mac-broadcast.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/nwfilter/230-no-mac-broadcast.t b/scripts/nwfilter/230-no-mac-broadcast.t index 6ab20d8..758005c 100644 --- a/scripts/nwfilter/230-no-mac-broadcast.t +++ b/scripts/nwfilter/230-no-mac-broadcast.t @@ -80,7 +80,7 @@ ok($ebtable =~ "-d Broadcast -j DROP", "check ebtables entry for \"-d Broadcast # prepare tcpdump diag "prepare tcpdump"; -system("/usr/sbin/tcpdump -v -i virbr0 -n host 255.255.255.255 2> /tmp/tcpdump.log &"); +system("/usr/sbin/tcpdump -v -i virbr0 -n host 192.168.122.255 and ether host ff:ff:ff:ff:ff:ff 2> /tmp/tcpdump.log &"); # log into guest diag "ssh'ing into $guestip"; -- 2.14.3

On 02/08/2018 02:19 PM, Laine Stump wrote:
In the no-mac-broadcast test, a ping is sent to 192.168.122.255, but tcpdump is set to look for packets with a destination IP of 255.255.255.255. Change it to check for the correct IP address and also for mac broadcast (which is what the no-mac-broadcast filter actually looks at). This should eliminate the "false success" that was happening because tcpdump wasn't actually seeing the broadcast packet the guest was sending, as well as catching the "false failure" caused by tcpdump seeing other traffic from the guest unrelated to the test (which happened to be broadcasts sent to 255.255.255.255).
Signed-off-by: Laine Stump <laine@laine.org> Review-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
Unchanged from V1, it just had no review.
scripts/nwfilter/230-no-mac-broadcast.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nwfilter/230-no-mac-broadcast.t b/scripts/nwfilter/230-no-mac-broadcast.t index 6ab20d8..758005c 100644 --- a/scripts/nwfilter/230-no-mac-broadcast.t +++ b/scripts/nwfilter/230-no-mac-broadcast.t @@ -80,7 +80,7 @@ ok($ebtable =~ "-d Broadcast -j DROP", "check ebtables entry for \"-d Broadcast
# prepare tcpdump diag "prepare tcpdump"; -system("/usr/sbin/tcpdump -v -i virbr0 -n host 255.255.255.255 2> /tmp/tcpdump.log &"); +system("/usr/sbin/tcpdump -v -i virbr0 -n host 192.168.122.255 and ether host ff:ff:ff:ff:ff:ff 2> /tmp/tcpdump.log &");
# log into guest diag "ssh'ing into $guestip";

On Thu, Feb 08, 2018 at 02:19:37PM -0500, Laine Stump wrote:
In the no-mac-broadcast test, a ping is sent to 192.168.122.255, but tcpdump is set to look for packets with a destination IP of 255.255.255.255. Change it to check for the correct IP address and also for mac broadcast (which is what the no-mac-broadcast filter actually looks at). This should eliminate the "false success" that was happening because tcpdump wasn't actually seeing the broadcast packet the guest was sending, as well as catching the "false failure" caused by tcpdump seeing other traffic from the guest unrelated to the test (which happened to be broadcasts sent to 255.255.255.255).
Signed-off-by: Laine Stump <laine@laine.org> ---
Unchanged from V1, it just had no review.
scripts/nwfilter/230-no-mac-broadcast.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

This test changes the IP address of the guest interface so that it can send out a packet with a different source IP address. It may have worked properly with older versions of Fedora running on the test guest, but at least in Fedora 27, NetworkManager keeps the dhclient process running after it has already acquired an IP address, and if you set the interface offline and then back on, dhclient will very quickly re-acquire the IP address, so the test ends up sending a ping from the *same* address, the packet passes the filters, and the test fails. The solution is to just kill the dhclient process. This allows the manually set IP address to "stick". Since the guest is shutdown immediately after this test, it doesn't matter that dhclient is no longer running. (We *do* need to set the IP address back to its original setting though, so that the ssh socket used for the test (which is connecting via the same interface) won't hang and delay completion of the test (also causing it to fail). Signed-off-by: Laine Stump <laine@laine.org> --- "New" in V2 - this line was previously sneaked into the middle of the patch that removed path specifiers from binary names in guest-side scripts, but it really deserves an explanation. scripts/nwfilter/220-no-ip-spoofing.t | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/nwfilter/220-no-ip-spoofing.t b/scripts/nwfilter/220-no-ip-spoofing.t index 72dcae8..9e1bb70 100644 --- a/scripts/nwfilter/220-no-ip-spoofing.t +++ b/scripts/nwfilter/220-no-ip-spoofing.t @@ -83,6 +83,7 @@ my $cmdfile = <<EOF; echo "DEV=\\\$(ip link | head -3 | tail -1 | awk '{print \\\$2}' | sed -e 's/://') MASK=\\\$(ip addr show \\\$DEV | grep 'inet ' | awk '{print \\\$2}' | sed -e 's/.*\\///;q') ip addr show \\\$DEV +kill \\\$(pidof dhclient) ip link set \\\$DEV down ip addr flush dev \\\$DEV ip addr add 192.168.122.183/\\\$MASK dev \\\$DEV -- 2.14.3

On 02/08/2018 02:19 PM, Laine Stump wrote:
This test changes the IP address of the guest interface so that it can send out a packet with a different source IP address. It may have worked properly with older versions of Fedora running on the test guest, but at least in Fedora 27, NetworkManager keeps the dhclient process running after it has already acquired an IP address, and if you set the interface offline and then back on, dhclient will very quickly re-acquire the IP address, so the test ends up sending a ping from the *same* address, the packet passes the filters, and the test fails.
The solution is to just kill the dhclient process. This allows the manually set IP address to "stick". Since the guest is shutdown immediately after this test, it doesn't matter that dhclient is no longer running. (We *do* need to set the IP address back to its original setting though, so that the ssh socket used for the test (which is connecting via the same interface) won't hang and delay completion of the test (also causing it to fail).
Signed-off-by: Laine Stump <laine@laine.org> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
"New" in V2 - this line was previously sneaked into the middle of the patch that removed path specifiers from binary names in guest-side scripts, but it really deserves an explanation.
scripts/nwfilter/220-no-ip-spoofing.t | 1 + 1 file changed, 1 insertion(+)
diff --git a/scripts/nwfilter/220-no-ip-spoofing.t b/scripts/nwfilter/220-no-ip-spoofing.t index 72dcae8..9e1bb70 100644 --- a/scripts/nwfilter/220-no-ip-spoofing.t +++ b/scripts/nwfilter/220-no-ip-spoofing.t @@ -83,6 +83,7 @@ my $cmdfile = <<EOF; echo "DEV=\\\$(ip link | head -3 | tail -1 | awk '{print \\\$2}' | sed -e 's/://') MASK=\\\$(ip addr show \\\$DEV | grep 'inet ' | awk '{print \\\$2}' | sed -e 's/.*\\///;q') ip addr show \\\$DEV +kill \\\$(pidof dhclient) ip link set \\\$DEV down ip addr flush dev \\\$DEV ip addr add 192.168.122.183/\\\$MASK dev \\\$DEV

On Thu, Feb 08, 2018 at 02:19:38PM -0500, Laine Stump wrote:
This test changes the IP address of the guest interface so that it can send out a packet with a different source IP address. It may have worked properly with older versions of Fedora running on the test guest, but at least in Fedora 27, NetworkManager keeps the dhclient process running after it has already acquired an IP address, and if you set the interface offline and then back on, dhclient will very quickly re-acquire the IP address, so the test ends up sending a ping from the *same* address, the packet passes the filters, and the test fails.
The solution is to just kill the dhclient process. This allows the manually set IP address to "stick". Since the guest is shutdown immediately after this test, it doesn't matter that dhclient is no longer running. (We *do* need to set the IP address back to its original setting though, so that the ssh socket used for the test (which is connecting via the same interface) won't hang and delay completion of the test (also causing it to fail).
Signed-off-by: Laine Stump <laine@laine.org> ---
"New" in V2 - this line was previously sneaked into the middle of the patch that removed path specifiers from binary names in guest-side scripts, but it really deserves an explanation.
scripts/nwfilter/220-no-ip-spoofing.t | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

verified that only tabs were removed by running "git diff -w". Signed-off-by: Laine Stump <laine@laine.org> --- lib/Sys/Virt/TCK.pm | 544 +++++++++++------------ lib/Sys/Virt/TCK/Capabilities.pm | 84 ++-- lib/Sys/Virt/TCK/DomainBuilder.pm | 312 ++++++------- lib/Sys/Virt/TCK/NetworkBuilder.pm | 44 +- lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 +- lib/Sys/Virt/TCK/SELinux.pm | 6 +- lib/Sys/Virt/TCK/StoragePoolBuilder.pm | 40 +- lib/Sys/Virt/TCK/StorageVolBuilder.pm | 48 +- lib/Sys/Virt/TCK/TAP/XMLFormatter.pm | 18 +- lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm | 66 +-- scripts/nwfilter/300-vsitype.t | 2 +- scripts/nwfilter/concurrency/chg-vm-filter.sh | 18 +- scripts/nwfilter/concurrency/start-destroy-vm.sh | 20 +- scripts/nwfilter/nwfilter2vmtest.sh | 42 +- 14 files changed, 625 insertions(+), 625 deletions(-) diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index 2259042..3f650a8 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -52,14 +52,14 @@ sub new { my %params = @_; $self->{config} = $params{config} ? $params{config} : - Config::Record->new(file => ($ENV{LIBVIRT_TCK_CONFIG} || "/etc/tck.conf")); + Config::Record->new(file => ($ENV{LIBVIRT_TCK_CONFIG} || "/etc/tck.conf")); $self->{autoclean} = $params{autoclean} ? $params{autoclean} : - ($ENV{LIBVIRT_TCK_AUTOCLEAN} || 0); + ($ENV{LIBVIRT_TCK_AUTOCLEAN} || 0); if ($ENV{LIBVIRT_TCK_DEBUG}) { - $SIG{__WARN__} = sub { Carp::cluck $_[0]; }; - $SIG{__DIE__} = sub { Carp::confess $_[0]; }; + $SIG{__WARN__} = sub { Carp::cluck $_[0]; }; + $SIG{__DIE__} = sub { Carp::confess $_[0]; }; } bless $self, $class; @@ -112,32 +112,32 @@ sub sanity_check { my @doms = grep { $_->get_name =~ /^tck/ } $conn->list_domains; if (@doms) { - die "there is/are " . int(@doms) . " pre-existing active domain(s) in this driver"; + die "there is/are " . int(@doms) . " pre-existing active domain(s) in this driver"; } @doms = grep { $_->get_name =~ /^tck/ } $conn->list_defined_domains; if (@doms) { - die "there is/are " . int(@doms) . " pre-existing inactive domain(s) in this driver"; + die "there is/are " . int(@doms) . " pre-existing inactive domain(s) in this driver"; } my @nets = grep { $_->get_name =~ /^tck/ } $conn->list_networks; if (@nets) { - die "there is/are " . int(@nets) . " pre-existing active network(s) in this driver"; + die "there is/are " . int(@nets) . " pre-existing active network(s) in this driver"; } @nets = grep { $_->get_name =~ /^tck/ } $conn->list_defined_networks; if (@nets) { - die "there is/are " . int(@nets) . " pre-existing inactive network(s) in this driver"; + die "there is/are " . int(@nets) . " pre-existing inactive network(s) in this driver"; } my @pools = grep { $_->get_name =~ /^tck/ } $conn->list_storage_pools; if (@pools) { - die "there is/are " . int(@pools) . " pre-existing active storage_pool(s) in this driver"; + die "there is/are " . int(@pools) . " pre-existing active storage_pool(s) in this driver"; } @pools = grep { $_->get_name =~ /^tck/ } $conn->list_defined_storage_pools; if (@pools) { - die "there is/are " . int(@pools) . " pre-existing inactive storage_pool(s) in this driver"; + die "there is/are " . int(@pools) . " pre-existing inactive storage_pool(s) in this driver"; } } @@ -148,7 +148,7 @@ sub reset_snapshots { # Use eval as not all drivers support snapshots my @domss = eval { $dom->list_snapshots }; foreach my $domss (@domss) { - $domss->delete; + $domss->delete; } } @@ -158,16 +158,16 @@ sub reset_domains { my @doms = grep { $_->get_name =~ /^tck/ } $conn->list_domains; foreach my $dom (@doms) { - $self->reset_snapshots($dom); - if ($dom->get_id != 0) { - $dom->destroy; - } + $self->reset_snapshots($dom); + if ($dom->get_id != 0) { + $dom->destroy; + } } @doms = grep { $_->get_name =~ /^tck/ } $conn->list_defined_domains(); foreach my $dom (@doms) { - $self->reset_snapshots($dom); - $dom->undefine; + $self->reset_snapshots($dom); + $dom->undefine; } } @@ -177,14 +177,14 @@ sub reset_networks { my @nets = grep { $_->get_name =~ /^tck/ } $conn->list_networks; foreach my $net (@nets) { - if ($net->is_active()) { - $net->destroy; - } + if ($net->is_active()) { + $net->destroy; + } } @nets = grep { $_->get_name =~ /^tck/ } $conn->list_defined_networks(); foreach my $net (@nets) { - $net->undefine; + $net->undefine; } } @@ -194,19 +194,19 @@ sub reset_storage_pools { my @pools = grep { $_->get_name =~ /^tck/ } $conn->list_storage_pools; foreach my $pool (@pools) { - my @vols = $pool->list_volumes; - foreach my $vol (@vols) { - eval { $vol->delete(0) }; - } - $pool->destroy; + my @vols = $pool->list_volumes; + foreach my $vol (@vols) { + eval { $vol->delete(0) }; + } + $pool->destroy; } @pools = grep { $_->get_name =~ /^tck/ } $conn->list_defined_storage_pools(); foreach my $pool (@pools) { - eval { - $pool->delete(0); - }; - $pool->undefine; + eval { + $pool->delete(0); + }; + $pool->undefine; } } @@ -224,7 +224,7 @@ sub cleanup { my $self = shift; foreach my $conn (@{$self->{conns}}) { - $self->reset($conn); + $self->reset($conn); } delete $self->{conns}; @@ -234,10 +234,10 @@ sub config { my $self = shift; my $key = shift; if (@_) { - my $default = shift; - return $self->{config}->get($key, $default); + my $default = shift; + return $self->{config}->get($key, $default); } else { - return $self->{config}->get($key); + return $self->{config}->get($key); } } @@ -253,8 +253,8 @@ sub scratch_dir { my $self = shift; my $scratch = $self->config("scratch_dir", $< > 0 ? - catdir(cwd(), "libvirt-tck") : - catdir(rootdir(), "var", "cache", "libvirt-tck")); + catdir(cwd(), "libvirt-tck") : + catdir(rootdir(), "var", "cache", "libvirt-tck")); mkpath($scratch) unless -e $scratch; @@ -286,14 +286,14 @@ sub get_scratch_resource { my $uncompress = undef; if (ref($source)) { - $uncompress = $source->{uncompress}; - $source = $source->{source}; + $uncompress = $source->{uncompress}; + $source = $source->{source}; } if ($source =~ m,^/,) { - $self->copy_scratch($source, $target, $uncompress); + $self->copy_scratch($source, $target, $uncompress); } else { - $self->download_scratch($source, $target, $uncompress); + $self->download_scratch($source, $target, $uncompress); } return $target; @@ -314,22 +314,22 @@ sub download_scratch { my $response = $ua->get($source); if ($response->is_success) { - open TGT, ">$target" or die "cannot create $target: $!"; - if (defined $uncompress) { - my $data = $response->content; - if ($uncompress eq "gzip") { - gunzip \$data => \*TGT; - } elsif ($uncompress eq "bzip2") { - bunzip2 \$data => \*TGT; - } else { - die "unknown compression method '$uncompress'"; - } - } else { - print TGT $response->content or die "cannot write $target: $!"; - } - close TGT or die "cannot save $target: $!"; + open TGT, ">$target" or die "cannot create $target: $!"; + if (defined $uncompress) { + my $data = $response->content; + if ($uncompress eq "gzip") { + gunzip \$data => \*TGT; + } elsif ($uncompress eq "bzip2") { + bunzip2 \$data => \*TGT; + } else { + die "unknown compression method '$uncompress'"; + } + } else { + print TGT $response->content or die "cannot write $target: $!"; + } + close TGT or die "cannot save $target: $!"; } else { - die "cannot download $source: " . $response->status_line; + die "cannot download $source: " . $response->status_line; } } @@ -342,15 +342,15 @@ sub copy_scratch { print "# copying $source\n"; if (defined $uncompress) { - if ($uncompress eq "gzip") { - gunzip $source => $target; - } elsif ($uncompress eq "bzip2") { - bunzip2 $source => $target; - } else { - die "unknown compression method '$uncompress'"; - } + if ($uncompress eq "gzip") { + gunzip $source => $target; + } elsif ($uncompress eq "bzip2") { + bunzip2 $source => $target; + } else { + die "unknown compression method '$uncompress'"; + } } else { - copy ($source, $target) or die "cannot copy $source to $target: $!"; + copy ($source, $target) or die "cannot copy $source to $target: $!"; } } @@ -401,7 +401,7 @@ sub create_virt_builder_disk { my $password = $self->root_password; if ($self->has_disk_image($bucket, $name, $osname)) { - return $target; + return $target; } print "# running virt-builder $osname\n"; @@ -448,9 +448,9 @@ sub create_minimal_vroot { my @dirs = qw(sbin bin dev proc sys tmp); foreach my $dir (@dirs) { - my $fulldir = catdir($target, $dir); - next if -e $fulldir; - mkpath($fulldir); + my $fulldir = catdir($target, $dir); + next if -e $fulldir; + mkpath($fulldir); } my $dst = catfile($target, "sbin", "busybox"); @@ -514,10 +514,10 @@ dumpleases iptunnel pidof sum echo kbd_mode ping sv); foreach my $file (@links) { - my $fullfile = catfile($target, "bin", $file); - next if -e $fullfile; - symlink "../sbin/busybox", $fullfile - or die "cannot symlink $fullfile to ../sbin/busybox: $!"; + my $fullfile = catfile($target, "bin", $file); + next if -e $fullfile; + symlink "../sbin/busybox", $fullfile + or die "cannot symlink $fullfile to ../sbin/busybox: $!"; } my $init = catfile($target, "sbin", "init"); @@ -541,18 +541,18 @@ sub best_domain { my $ostype = shift; for (my $i = 0 ; $i < $caps->num_guests ; $i++) { - if ($caps->guest_os_type($i) eq $ostype && - $caps->guest_arch_name($i) eq $caps->host_cpu_arch()) { + if ($caps->guest_os_type($i) eq $ostype && + $caps->guest_arch_name($i) eq $caps->host_cpu_arch()) { - my @domains = $caps->guest_domain_types($i); - next unless int(@domains); + my @domains = $caps->guest_domain_types($i); + next unless int(@domains); - # Prefer kvm if multiple domain types are returned - my $domain = (grep /^kvm$/, @domains) ? "kvm" : $domains[0]; + # Prefer kvm if multiple domain types are returned + my $domain = (grep /^kvm$/, @domains) ? "kvm" : $domains[0]; - return ($domain, - $caps->host_cpu_arch()); - } + return ($domain, + $caps->host_cpu_arch()); + } } return (); @@ -566,19 +566,19 @@ sub match_guest_domain { my $ostype = shift; for (my $i = 0 ; $i < $caps->num_guests ; $i++) { - if ($caps->guest_os_type($i) eq $ostype && - $caps->guest_arch_name($i) eq $arch) { + if ($caps->guest_os_type($i) eq $ostype && + $caps->guest_arch_name($i) eq $arch) { - my @domains = $caps->guest_domain_types($i); - next unless int(@domains); + my @domains = $caps->guest_domain_types($i); + next unless int(@domains); - # Prefer kvm if multiple domain types are returned - my $domain = (grep /^kvm$/, @domains) ? "kvm" : $domains[0]; + # Prefer kvm if multiple domain types are returned + my $domain = (grep /^kvm$/, @domains) ? "kvm" : $domains[0]; - return ($domain, - $caps->guest_domain_emulator($i, $domain), - $caps->guest_domain_loader($i, $domain)); - } + return ($domain, + $caps->guest_domain_emulator($i, $domain), + $caps->guest_domain_loader($i, $domain)); + } } return (); @@ -594,25 +594,25 @@ sub best_kernel { my $hostarch = $caps->host_cpu_arch(); for (my $i = 0 ; $i <= $#{$kernels} ; $i++) { - my $arch = $kernels->[$i]->{arch}; - my $ostype = $kernels->[$i]->{ostype}; - my @ostype = ref($ostype) ? @{$ostype} : ($ostype); + my $arch = $kernels->[$i]->{arch}; + my $ostype = $kernels->[$i]->{ostype}; + my @ostype = ref($ostype) ? @{$ostype} : ($ostype); - next unless $arch eq $hostarch; + next unless $arch eq $hostarch; - foreach $ostype (@ostype) { - if ((defined $wantostype) && - ($wantostype ne $ostype)) { - next; - } + foreach $ostype (@ostype) { + if ((defined $wantostype) && + ($wantostype ne $ostype)) { + next; + } - my ($domain, $emulator, $loader) = - $self->match_guest_domain($caps, $arch, $ostype); + my ($domain, $emulator, $loader) = + $self->match_guest_domain($caps, $arch, $ostype); - if (defined $domain) { - return ($i, $domain, $arch, $ostype, $emulator, $loader) - } - } + if (defined $domain) { + return ($i, $domain, $arch, $ostype, $emulator, $loader) + } + } } return (); @@ -629,25 +629,25 @@ sub best_image { my $hostarch = $caps->host_cpu_arch(); for (my $i = 0 ; $i <= $#{$images} ; $i++) { - my $arch = $images->[$i]->{arch}; - my $ostype = $images->[$i]->{ostype}; - my @ostype = ref($ostype) ? @{$ostype} : ($ostype); + my $arch = $images->[$i]->{arch}; + my $ostype = $images->[$i]->{ostype}; + my @ostype = ref($ostype) ? @{$ostype} : ($ostype); - next unless $arch eq $hostarch; + next unless $arch eq $hostarch; - foreach $ostype (@ostype) { - if ((defined $wantostype) && - ($wantostype ne $ostype)) { - next; - } + foreach $ostype (@ostype) { + if ((defined $wantostype) && + ($wantostype ne $ostype)) { + next; + } - my ($domain, $emulator, $loader) = - $self->match_guest_domain($caps, $arch, $ostype); + my ($domain, $emulator, $loader) = + $self->match_guest_domain($caps, $arch, $ostype); - if (defined $domain) { - return ($i, $domain, $arch, $ostype, $emulator, $loader) - } - } + if (defined $domain) { + return ($i, $domain, $arch, $ostype, $emulator, $loader) + } + } } return (); @@ -660,17 +660,17 @@ sub get_disk_dev { my $dev; if ($ostype eq "xen") { - $dev = "xvda"; + $dev = "xvda"; } elsif ($ostype eq "uml") { - $dev = "ubda"; + $dev = "ubda"; } elsif ($ostype eq "hvm") { - if ($domain eq "kvm" || - $domain eq "qemu" || - $domain eq "kqemu") { - $dev = "vda"; - } else { - $dev = "hda"; - } + if ($domain eq "kvm" || + $domain eq "qemu" || + $domain eq "kqemu") { + $dev = "vda"; + } else { + $dev = "hda"; + } } return $dev; } @@ -682,10 +682,10 @@ sub get_kernel { my $wantostype = shift; my ($cfgindex, $domain, $arch, $ostype, $emulator, $loader) = - $self->best_kernel($caps, $wantostype); + $self->best_kernel($caps, $wantostype); if (!defined $cfgindex) { - die "cannot find any supported kernel configuration"; + die "cannot find any supported kernel configuration"; } my $kernels = $self->config("kernels", []); @@ -701,7 +701,7 @@ sub get_kernel { my $dfile = $disk ? $self->get_scratch_resource($disk, $bucket, "disk.img") : undef; unless (defined $dfile) { - $dfile = $self->create_sparse_disk($bucket, "disk.img", 100); + $dfile = $self->create_sparse_disk($bucket, "disk.img", 100); } chmod 0755, $kfile; @@ -709,15 +709,15 @@ sub get_kernel { my $dev = $self->get_disk_dev($ostype, $domain); return ( - domain => $domain, - arch => $arch, - ostype => $ostype, - emulator => $emulator, - loader => $loader, - kernel => $kfile, - initrd => $ifile, - root => $dfile, - dev => $dev, + domain => $domain, + arch => $arch, + ostype => $ostype, + emulator => $emulator, + loader => $loader, + kernel => $kfile, + initrd => $ifile, + root => $dfile, + dev => $dev, ); } @@ -728,10 +728,10 @@ sub get_image { my $wantostype = shift; my ($cfgindex, $domain, $arch, $ostype, $emulator, $loader) = - $self->best_image($caps, $wantostype); + $self->best_image($caps, $wantostype); if (!defined $cfgindex) { - die "cannot find any supported image configuration"; + die "cannot find any supported image configuration"; } my $kernels = $self->config("images", []); @@ -746,13 +746,13 @@ sub get_image { my $dev = $self->get_disk_dev($ostype, $domain); return ( - domain => $domain, - arch => $arch, - ostype => $ostype, - emulator => $emulator, - loader => $loader, - root => $dfile, - dev => $dev, + domain => $domain, + arch => $arch, + ostype => $ostype, + emulator => $emulator, + loader => $loader, + root => $dfile, + dev => $dev, firstboot => $needs_firstboot, ); } @@ -769,78 +769,78 @@ sub generic_machine_domain { my $filterref = exists $params{filterref} ? $params{filterref} : undef; if ($fullos) { - my %config = $self->get_image($caps, $ostype); + my %config = $self->get_image($caps, $ostype); my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->conn, - name => $name, - arch => $config{arch}, - domain => $config{domain}, - ostype => $config{ostype}); - $b->memory(1024 * 1024); - $b->with_acpi(); - $b->with_apic(); + name => $name, + arch => $config{arch}, + domain => $config{domain}, + ostype => $config{ostype}); + $b->memory(1024 * 1024); + $b->with_acpi(); + $b->with_apic(); - $b->boot_disk(); + $b->boot_disk(); - $b->disk(src => $config{root}, - dst => $config{dev}, - type => "file"); + $b->disk(src => $config{root}, + dst => $config{dev}, + type => "file"); - if ($config{firstboot}) { - print "# Running the first boot\n"; + if ($config{firstboot}) { + print "# Running the first boot\n"; - $b->interface(type => "network", - source => "default", + $b->interface(type => "network", + source => "default", model => "virtio", - mac => "52:54:00:11:11:11", - filterref => $filterref); - my $xml = $b->as_xml(); - # Cleanup the temporary interface - $b->rminterface(); - - my $dom = $self->conn->define_domain($xml); - $dom->create(); - - # Wait for the first boot to reach network setting - my $stats; - my $tries = 0; - do { - sleep(10); - $stats = $dom->interface_stats("vnet0"); - $tries++; - } while ($stats->{"tx_packets"} < 10 && $tries < 10); - - # Safe to shutdown domain now - my $target = time() + 30; - $dom->shutdown; - while ($dom->is_active()) { - sleep(1); - $dom->destroy() if time() > $target; - } - sleep(1); - $dom->undefine(); - } - - return $b; + mac => "52:54:00:11:11:11", + filterref => $filterref); + my $xml = $b->as_xml(); + # Cleanup the temporary interface + $b->rminterface(); + + my $dom = $self->conn->define_domain($xml); + $dom->create(); + + # Wait for the first boot to reach network setting + my $stats; + my $tries = 0; + do { + sleep(10); + $stats = $dom->interface_stats("vnet0"); + $tries++; + } while ($stats->{"tx_packets"} < 10 && $tries < 10); + + # Safe to shutdown domain now + my $target = time() + 30; + $dom->shutdown; + while ($dom->is_active()) { + sleep(1); + $dom->destroy() if time() > $target; + } + sleep(1); + $dom->undefine(); + } + + return $b; } else { - my %config = $self->get_kernel($caps, $ostype); - - my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->conn, - name => $name, - arch => $config{arch}, - domain => $config{domain}, - ostype => $config{ostype}); - $b->memory(1024 * 1024); - $b->with_acpi(); - $b->with_apic(); - - # XXX boot CDROM or vroot for other HVs - $b->boot_kernel($config{kernel}, $config{initrd}); - - $b->disk(src => $config{root}, - dst => $config{dev}, - type => "file"); - return $b; + my %config = $self->get_kernel($caps, $ostype); + + my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->conn, + name => $name, + arch => $config{arch}, + domain => $config{domain}, + ostype => $config{ostype}); + $b->memory(1024 * 1024); + $b->with_acpi(); + $b->with_apic(); + + # XXX boot CDROM or vroot for other HVs + $b->boot_kernel($config{kernel}, $config{initrd}); + + $b->disk(src => $config{root}, + dst => $config{dev}, + type => "file"); + return $b; } } @@ -850,12 +850,12 @@ sub best_container_domain { my $caps = shift; for (my $i = 0 ; $i < $caps->num_guests ; $i++) { - if ($caps->guest_os_type($i) eq "exe") { - my @domains = $caps->guest_domain_types($i); - next unless int(@domains); + if ($caps->guest_os_type($i) eq "exe") { + my @domains = $caps->guest_domain_types($i); + next unless int(@domains); - return $domains[0]; - } + return $domains[0]; + } } return undef; @@ -872,9 +872,9 @@ sub generic_container_domain { my $bucket = "os-exe"; my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->conn, - name => $name, - domain => $domain, - ostype => "exe"); + name => $name, + domain => $domain, + ostype => "exe"); $b->memory(64 * 1024); my ($root, $init) = $self->create_minimal_vroot($bucket, $name); @@ -882,8 +882,8 @@ sub generic_container_domain { $b->boot_init($init); $b->filesystem(src => $root, - dst => "/", - type => "mount"); + dst => "/", + type => "mount"); return $b; } @@ -904,38 +904,38 @@ sub generic_domain { my $container; $container = $self->best_container_domain($caps) - unless $ostype && $ostype ne "exe"; + unless $ostype && $ostype ne "exe"; my $b; if ($container) { - die "Full provisioned OS not supported with containers yet" if $fullos; + die "Full provisioned OS not supported with containers yet" if $fullos; - $b = $self->generic_container_domain(name => $name, - caps => $caps, - domain => $container); + $b = $self->generic_container_domain(name => $name, + caps => $caps, + domain => $container); } else { - $b = $self->generic_machine_domain(name => $name, - caps => $caps, - ostype => $ostype, + $b = $self->generic_machine_domain(name => $name, + caps => $caps, + ostype => $ostype, fullos => $fullos, filterref => $filterref); } if ($netmode) { - if ($netmode eq "vepa") { - $b->interface(type => "direct", - source => "default", + if ($netmode eq "vepa") { + $b->interface(type => "direct", + source => "default", model => "virtio", - mac => "52:54:00:11:11:11", - dev => $self->get_host_network_device(), - mode => "vepa", - virtualport => "802.1Qbg"); - } else { - $b->interface(type => "network", - source => "default", + mac => "52:54:00:11:11:11", + dev => $self->get_host_network_device(), + mode => "vepa", + virtualport => "802.1Qbg"); + } else { + $b->interface(type => "network", + source => "default", model => "virtio", - mac => "52:54:00:11:11:11", - filterref => $filterref); - } + mac => "52:54:00:11:11:11", + filterref => $filterref); + } } return $b; } @@ -948,7 +948,7 @@ sub generic_pool { my $bucket = $self->bucket_dir("storage-fs"); my $b = Sys::Virt::TCK::StoragePoolBuilder->new(name => $name, - type => $type); + type => $type); $b->target(catdir($bucket, $name)); @@ -994,7 +994,7 @@ sub _quiet_caller (;$) { ## no critic Prototypes else { return CORE::caller($height); } - } + } sub _try_as_caller { my $coderef = shift; @@ -1018,26 +1018,26 @@ sub ok_object($$$;$) { my $name = shift; die "must pass coderef, class, description and (optional) expected name" - unless defined $description; + unless defined $description; my ($ret, $exception) = _try_as_caller($coderef, 4); my $ok = "$exception" eq "" && - $ret && ref($ret) && $ret->isa($class) && - (!defined $name || ($ret->get_name() eq $name)); + $ret && ref($ret) && $ret->isa($class) && + (!defined $name || ($ret->get_name() eq $name)); $Tester->ok($ok, $description); unless ($ok) { - $Tester->diag("expected $class object" . ($name ? " with name $name" : "")); - if ($exception) { - $Tester->diag("found '$exception'"); - } else { - if ($ret && ref($ret) && $ret->isa($class)) { - $Tester->diag("found $class object with name " . $ret->get_name); - } else { - $Tester->diag("found '$ret'"); - } - } + $Tester->diag("expected $class object" . ($name ? " with name $name" : "")); + if ($exception) { + $Tester->diag("found '$exception'"); + } else { + if ($ret && ref($ret) && $ret->isa($class)) { + $Tester->diag("found $class object with name " . $ret->get_name); + } else { + $Tester->diag("found '$ret'"); + } + } } } @@ -1104,17 +1104,17 @@ sub ok_error(&$;$) { my $code = shift; die "must pass coderef, description and (optional) expected error code" - unless defined $description; + unless defined $description; my ($ret, $exception) = _try_as_caller($coderef, 3); my $ok = ref($exception) && $exception->isa("Sys::Virt::Error") && - (!defined $code || ($exception->code() == $code)); + (!defined $code || ($exception->code() == $code)); $Tester->ok($ok, $description); unless ($ok) { - $Tester->diag("expecting Sys::Virt::Error object" . ($code ? " with code $code" : "")); - $Tester->diag("found '$exception'"); + $Tester->diag("expecting Sys::Virt::Error object" . ($code ? " with code $code" : "")); + $Tester->diag("found '$exception'"); } $@ = $exception; return $ok; @@ -1125,10 +1125,10 @@ sub err_not_implemented { my $exception = shift; if ($exception && - ref($exception) && - $exception->isa("Sys::Virt::Error") && - $exception->code() == 3) { - return 1; + ref($exception) && + $exception->isa("Sys::Virt::Error") && + $exception->code() == 3) { + return 1; } return 0; } @@ -1151,7 +1151,7 @@ sub get_host_usb_device { my $devs = $self->config("host_usb_devices", []); if ($devindex > $#{$devs}) { - return (); + return (); } my $bus = $self->config("host_usb_devices/[$devindex]/bus", undef); @@ -1169,7 +1169,7 @@ sub get_host_pci_device { my $devs = $self->config("host_pci_devices", []); if ($devindex > $#{$devs}) { - return (); + return (); } my $domain = $self->config("host_pci_devices/[$devindex]/domain", 0); @@ -1185,7 +1185,7 @@ sub get_host_block_device { my $devindex = @_ ? shift : 0; my $device = ($self->config("host_block_devices/[$devindex]/path", undef) - || $self->config("host_block_devices/[$devindex]", undef)); + || $self->config("host_block_devices/[$devindex]", undef)); return undef unless $device; my $kb_blocks = $self->config("host_block_devices/[$devindex]/size", 0); @@ -1193,7 +1193,7 @@ sub get_host_block_device { # Filter out devices that the current user can't open. sysopen(BLK, $device, O_RDONLY) or return undef; my $match = ($kb_blocks ? sysseek(BLK, 0, SEEK_END) == $kb_blocks * 1024 - : 1); + : 1); close BLK; return $match ? $device : undef; diff --git a/lib/Sys/Virt/TCK/Capabilities.pm b/lib/Sys/Virt/TCK/Capabilities.pm index 281f41e..ef2c87a 100644 --- a/lib/Sys/Virt/TCK/Capabilities.pm +++ b/lib/Sys/Virt/TCK/Capabilities.pm @@ -59,7 +59,7 @@ sub _parse_capabilities { $self->_parse_host($host) if $host; foreach my $child ($node->children("guest")) { - $self->_parse_guest($child); + $self->_parse_guest($child); } } @@ -92,11 +92,11 @@ sub _parse_host_cpu { my $feat = $node->first_child("features"); if (defined $feat) { - $cpu->{features} = {}; - foreach my $child ($feat->children()) { - my $name = $child->name; - $cpu->{features}->{$name} = 1; - } + $cpu->{features} = {}; + foreach my $child ($feat->children()) { + my $name = $child->name; + $cpu->{features}->{$name} = 1; + } } $self->{host}->{cpu} = $cpu; @@ -116,9 +116,9 @@ sub _parse_host_migration { $mig->{transports} = []; my $trans = $node->first_child("uri_transports"); if (defined $trans) { - foreach my $child ($trans->children("uri_transport")) { - push @{$mig->{transports}}, $child->text; - } + foreach my $child ($trans->children("uri_transport")) { + push @{$mig->{transports}}, $child->text; + } } $self->{host}->{migration} = $mig; @@ -136,16 +136,16 @@ sub _parse_host_topology { my @cells; foreach my $cell ($cells->children("cell")) { - my $topcell = []; - push @{$top}, $topcell; + my $topcell = []; + push @{$top}, $topcell; - my $cpus = $cell->first_child("cpus"); - next unless $cpus; + my $cpus = $cell->first_child("cpus"); + next unless $cpus; - foreach my $cpu ($cpus->children("cpu")) { - my $id = $cpu->att("id"); - push @{$topcell}, $id; - } + foreach my $cpu ($cpus->children("cpu")) { + my $id = $cpu->att("id"); + push @{$topcell}, $id; + } } $self->{host}->{topology} = $top; @@ -156,8 +156,8 @@ sub _parse_host_secmodel { my $node = shift; my $sec = { - model => $node->first_child_text("model"), - doi => $node->first_child_text("doi"), + model => $node->first_child_text("model"), + doi => $node->first_child_text("doi"), }; $self->{host}->{secmodel} = $sec; @@ -175,44 +175,44 @@ sub _parse_guest { my $wordsize = $arch->first_child_text("wordsize"); $guest->{arch} = { - name => $arch->att("name"), - wordsize => $wordsize, - domains => {}, + name => $arch->att("name"), + wordsize => $wordsize, + domains => {}, }; my $defemu = $arch->first_child("emulator") ? $arch->first_child_text("emulator") : undef; my $defload = $arch->first_child("loader") ? $arch->first_child_text("loader") : undef; my @defmachines = (); foreach my $child ($arch->children("machine")) { - push @defmachines, $child->text; + push @defmachines, $child->text; } foreach my $dom ($arch->children("domain")) { - my $emu = $dom->first_child("emulator") ? $dom->first_child_text("emulator") : undef; - my $load = $dom->first_child("loader") ? $dom->first_child_text("loader") : undef; - my @machines = (); - foreach my $child ($dom->children("machine")) { - push @machines, $child->text; - } - $emu = $defemu unless $emu; - $load = $defload unless $load; - @machines = @defmachines unless @machines; - - my $type = $dom->att("type"); - $guest->{arch}->{domains}->{$type} = { - emulator => $emu, - loader => $load, - machines => \@machines, - }; + my $emu = $dom->first_child("emulator") ? $dom->first_child_text("emulator") : undef; + my $load = $dom->first_child("loader") ? $dom->first_child_text("loader") : undef; + my @machines = (); + foreach my $child ($dom->children("machine")) { + push @machines, $child->text; + } + $emu = $defemu unless $emu; + $load = $defload unless $load; + @machines = @defmachines unless @machines; + + my $type = $dom->att("type"); + $guest->{arch}->{domains}->{$type} = { + emulator => $emu, + loader => $load, + machines => \@machines, + }; } $guest->{features} = {}; my $features = $node->first_child("features"); if ($features) { - foreach my $child ($features->children) { - $guest->{features}->{$child->name} = 1; - } + foreach my $child ($features->children) { + $guest->{features}->{$child->name} = 1; + } } push @{$self->{guests}}, $guest; diff --git a/lib/Sys/Virt/TCK/DomainBuilder.pm b/lib/Sys/Virt/TCK/DomainBuilder.pm index e9453ee..fb9a31f 100644 --- a/lib/Sys/Virt/TCK/DomainBuilder.pm +++ b/lib/Sys/Virt/TCK/DomainBuilder.pm @@ -31,24 +31,24 @@ sub new { my $ostype = $params{ostype} ? $params{ostype} : die "ostype parameter is required"; my $self = { - name => $params{name} ? $params{name} : "tck" , - type => $domain, - ostype => $ostype, - boot => { type => "disk" }, - arch => $params{arch} ? $params{arch} : undef, - emulator => undef, - lifecycle => {}, - features => {}, - disks => [], - filesystems => [], - interfaces => [], - serials => [], - parallels => [], - consoles => [], - inputs => [], - graphics => [], - hostdevs => [], - seclabel => {}, + name => $params{name} ? $params{name} : "tck" , + type => $domain, + ostype => $ostype, + boot => { type => "disk" }, + arch => $params{arch} ? $params{arch} : undef, + emulator => undef, + lifecycle => {}, + features => {}, + disks => [], + filesystems => [], + interfaces => [], + serials => [], + parallels => [], + consoles => [], + inputs => [], + graphics => [], + hostdevs => [], + seclabel => {}, }; bless $self, $class; @@ -61,7 +61,7 @@ sub memory { my $mem = shift; $self->{memory} = $mem - unless defined $self->{memory}; + unless defined $self->{memory}; $self->{currentMemory} = $mem; return $self; @@ -95,7 +95,7 @@ sub boot_network { my $self = shift; $self->{boot} = { - type => "network" + type => "network" }; return $self; @@ -105,7 +105,7 @@ sub boot_disk { my $self = shift; $self->{boot} = { - type => "disk" + type => "disk" }; return $self; @@ -115,7 +115,7 @@ sub boot_cdrom { my $self = shift; $self->{boot} = { - type => "cdrom" + type => "cdrom" }; return $self; @@ -125,7 +125,7 @@ sub boot_floppy { my $self = shift; $self->{boot} = { - type => "floppy" + type => "floppy" }; return $self; @@ -140,10 +140,10 @@ sub boot_kernel { die "kernel parameter is required" unless $kernel; $self->{boot} = { - type => "kernel", - kernel => $kernel, - ($initrd ? (initrd => $initrd) : ()), - ($cmdline ? (cmdline => $cmdline) : ()), + type => "kernel", + kernel => $kernel, + ($initrd ? (initrd => $initrd) : ()), + ($cmdline ? (cmdline => $cmdline) : ()), }; return $self; @@ -154,8 +154,8 @@ sub boot_bootloader { my $path = shift; $self->{boot} = { - type => "bootloader", - bootloader => $path + type => "bootloader", + bootloader => $path }; return $self; @@ -167,8 +167,8 @@ sub boot_init { my $path = shift; $self->{boot} = { - type => "init", - init => $path + type => "init", + init => $path }; return $self; @@ -182,10 +182,10 @@ sub boot_cmdline { my $initrd = $self->{boot}->{initrd}; $self->{boot} = { - type => "kernel", - kernel => $kernel, - initrd => $initrd, - cmdline => $cmdline + type => "kernel", + kernel => $kernel, + initrd => $initrd, + cmdline => $cmdline }; return $self; @@ -195,10 +195,10 @@ sub clear_kernel_initrd_cmdline { my $self = shift; $self->{boot} = { - type => "kernel", - kernel => "", - initrd => "", - cmdline => "" + type => "kernel", + kernel => "", + initrd => "", + cmdline => "" }; return $self; } @@ -334,168 +334,168 @@ sub as_xml { my $data; my $fh = IO::String->new(\$data); my $w = XML::Writer->new(OUTPUT => $fh, - DATA_MODE => 1, - DATA_INDENT => 2); + DATA_MODE => 1, + DATA_INDENT => 2); $w->startTag("domain", - "type" => $self->{type}); + "type" => $self->{type}); foreach (qw(name uuid memory currentMemory vcpu)) { - $w->dataElement("$_" => $self->{$_}) if $self->{$_}; + $w->dataElement("$_" => $self->{$_}) if $self->{$_}; } $w->startTag("os"); if ($self->{arch}) { - $w->dataElement("type", $self->{ostype}, arch => $self->{arch}); + $w->dataElement("type", $self->{ostype}, arch => $self->{arch}); } else { - $w->dataElement("type", $self->{ostype}); + $w->dataElement("type", $self->{ostype}); } if ($self->{boot}->{type} eq "disk") { - $w->emptyTag("boot", dev => "hd"); + $w->emptyTag("boot", dev => "hd"); } elsif ($self->{boot}->{type} eq "floppy") { - $w->emptyTag("boot", dev => "fd"); + $w->emptyTag("boot", dev => "fd"); } elsif ($self->{boot}->{type} eq "cdrom") { - $w->emptyTag("boot", dev => "cdrom"); + $w->emptyTag("boot", dev => "cdrom"); } elsif ($self->{boot}->{type} eq "network") { - $w->emptyTag("boot", dev => "network"); + $w->emptyTag("boot", dev => "network"); } elsif ($self->{boot}->{type} eq "kernel") { - foreach (qw(kernel initrd cmdline)) { - $w->dataElement($_, $self->{boot}->{$_}) if $self->{boot}->{$_}; - } + foreach (qw(kernel initrd cmdline)) { + $w->dataElement($_, $self->{boot}->{$_}) if $self->{boot}->{$_}; + } } elsif ($self->{boot}->{type} eq "init") { - $w->dataElement("init", $self->{boot}->{init}); + $w->dataElement("init", $self->{boot}->{init}); } if (exists $self->{boot}->{loader}) { - $w->dataElement("loader" => $self->{boot}->{loader}); + $w->dataElement("loader" => $self->{boot}->{loader}); } $w->endTag("os"); if ($self->{boot}->{type} eq "bootloader") { - $w->dataElement("bootloader" => $self->{boot}->{bootloader}); + $w->dataElement("bootloader" => $self->{boot}->{bootloader}); } foreach (qw(on_reboot on_poweroff on_crash)) { - $w->dataElement($_ => $self->{lifecycle}->{$_}) if $self->{lifecycle}->{$_}; + $w->dataElement($_ => $self->{lifecycle}->{$_}) if $self->{lifecycle}->{$_}; } if (%{$self->{features}}) { - $w->startTag("features"); - foreach (qw(pae acpi apic)) { - $w->emptyTag($_) if $self->{features}->{$_}; - } - $w->endTag("features"); + $w->startTag("features"); + foreach (qw(pae acpi apic)) { + $w->emptyTag($_) if $self->{features}->{$_}; + } + $w->endTag("features"); } $w->startTag("devices"); if ($self->{emulator}) { - $w->dataElement("emulator" => $self->{emulator}); + $w->dataElement("emulator" => $self->{emulator}); } foreach my $disk (@{$self->{disks}}) { - $w->startTag("disk", - type => $disk->{type}, - $disk->{device} ? (device => $disk->{device}) : ()); - - if ($disk->{format}) { - $w->emptyTag("driver", - name => $disk->{format}->{name}, - type => $disk->{format}->{type}); - } - - if ($disk->{type} eq "block") { - $w->emptyTag("source", - dev => $disk->{src}); - } else { - $w->emptyTag("source", - file => $disk->{src}); - } - $w->emptyTag("target", - dev => $disk->{dst}, - $disk->{bus} ? (bus => $disk->{bus}) : ()); - if ($disk->{secret}) { - $w->startTag("encryption", format => "qcow"); - $w->emptyTag("secret", type => "passphrase", uuid => $disk->{secret}); - $w->endTag("encryption"); - } - $w->endTag("disk"); + $w->startTag("disk", + type => $disk->{type}, + $disk->{device} ? (device => $disk->{device}) : ()); + + if ($disk->{format}) { + $w->emptyTag("driver", + name => $disk->{format}->{name}, + type => $disk->{format}->{type}); + } + + if ($disk->{type} eq "block") { + $w->emptyTag("source", + dev => $disk->{src}); + } else { + $w->emptyTag("source", + file => $disk->{src}); + } + $w->emptyTag("target", + dev => $disk->{dst}, + $disk->{bus} ? (bus => $disk->{bus}) : ()); + if ($disk->{secret}) { + $w->startTag("encryption", format => "qcow"); + $w->emptyTag("secret", type => "passphrase", uuid => $disk->{secret}); + $w->endTag("encryption"); + } + $w->endTag("disk"); } foreach my $fs (@{$self->{filesystems}}) { - $w->startTag("filesystem", - type => $fs->{type}); - - $w->emptyTag("source", - dir => $fs->{src}); - $w->emptyTag("target", - dir => $fs->{dst}); - $w->endTag("filesystem"); + $w->startTag("filesystem", + type => $fs->{type}); + + $w->emptyTag("source", + dir => $fs->{src}); + $w->emptyTag("target", + dir => $fs->{dst}); + $w->endTag("filesystem"); } foreach my $interface (@{$self->{interfaces}}) { - $w->startTag("interface", - type => $interface->{type}); - - $w->emptyTag("mac", - address => $interface->{mac}); - - if ($interface->{dev}) { - $w->emptyTag("source", - dev => $interface->{dev}, - mode => $interface->{mode}); - } else { - $w->emptyTag("source", - network => $interface->{source}); - } - if ($interface->{virtualport}) { - $w->startTag("virtualport", - type => $interface->{virtualport}); - $w->emptyTag("parameters", - managerid => '1', - typeid => '2', - typeidversion => '3', - instanceid => '40000000-0000-0000-0000-000000000000'); - $w->endTag("virtualport"); - } - if ($interface->{model}) { - $w->emptyTag("model", - type => $interface->{model}); - } - if ($interface->{filterref}) { - $w->emptyTag("filterref", - filter => $interface->{filterref}); - } - $w->endTag("interface"); + $w->startTag("interface", + type => $interface->{type}); + + $w->emptyTag("mac", + address => $interface->{mac}); + + if ($interface->{dev}) { + $w->emptyTag("source", + dev => $interface->{dev}, + mode => $interface->{mode}); + } else { + $w->emptyTag("source", + network => $interface->{source}); + } + if ($interface->{virtualport}) { + $w->startTag("virtualport", + type => $interface->{virtualport}); + $w->emptyTag("parameters", + managerid => '1', + typeid => '2', + typeidversion => '3', + instanceid => '40000000-0000-0000-0000-000000000000'); + $w->endTag("virtualport"); + } + if ($interface->{model}) { + $w->emptyTag("model", + type => $interface->{model}); + } + if ($interface->{filterref}) { + $w->emptyTag("filterref", + filter => $interface->{filterref}); + } + $w->endTag("interface"); } foreach my $graphic (@{$self->{graphics}}) { - $w->startTag("graphics", - type => $graphic->{type}); - - $w->emptyTag("port", - port => $graphic->{port}); - $w->emptyTag("autoport", - autoport => $graphic->{autoport}); - $w->emptyTag("listen", - listen => $graphic->{listen}, - $graphic->{listen_type} ? (type => $graphic->{listen_type}) : type => "address"); - $w->emptyTag("keymap", - keymap => $graphic->{keymap}); - $w->endTag("graphics"); + $w->startTag("graphics", + type => $graphic->{type}); + + $w->emptyTag("port", + port => $graphic->{port}); + $w->emptyTag("autoport", + autoport => $graphic->{autoport}); + $w->emptyTag("listen", + listen => $graphic->{listen}, + $graphic->{listen_type} ? (type => $graphic->{listen_type}) : type => "address"); + $w->emptyTag("keymap", + keymap => $graphic->{keymap}); + $w->endTag("graphics"); } $w->emptyTag("console", type => "pty"); $w->endTag("devices"); if ($self->{seclabel}->{model}) { - $w->startTag("seclabel", - model => $self->{seclabel}->{model}, - type => $self->{seclabel}->{type}, - relabel => $self->{seclabel}->{relabel}); - if ($self->{seclabel}->{label}) { - $w->dataElement("label", $self->{seclabel}->{label}); - } - if ($self->{seclabel}->{imagelabel}) { - $w->dataElement("imagelabel", $self->{seclabel}->{imagelabel}); - } - if ($self->{seclabel}->{baselabel}) { - $w->dataElement("baselabel", $self->{seclabel}->{baselabel}); - } - $w->endTag("seclabel"); + $w->startTag("seclabel", + model => $self->{seclabel}->{model}, + type => $self->{seclabel}->{type}, + relabel => $self->{seclabel}->{relabel}); + if ($self->{seclabel}->{label}) { + $w->dataElement("label", $self->{seclabel}->{label}); + } + if ($self->{seclabel}->{imagelabel}) { + $w->dataElement("imagelabel", $self->{seclabel}->{imagelabel}); + } + if ($self->{seclabel}->{baselabel}) { + $w->dataElement("baselabel", $self->{seclabel}->{baselabel}); + } + $w->endTag("seclabel"); } $w->endTag("domain"); diff --git a/lib/Sys/Virt/TCK/NetworkBuilder.pm b/lib/Sys/Virt/TCK/NetworkBuilder.pm index 2e6d8a1..09ca6b7 100644 --- a/lib/Sys/Virt/TCK/NetworkBuilder.pm +++ b/lib/Sys/Virt/TCK/NetworkBuilder.pm @@ -26,7 +26,7 @@ sub new { my %params = @_; my $self = { - name => $params{name} ? $params{name} : "tck" , + name => $params{name} ? $params{name} : "tck" , }; bless $self, $class; @@ -47,7 +47,7 @@ sub bridge { my $name = shift; $self->{bridge} = { name => $name, - @_ }; + @_ }; return $self; } @@ -88,35 +88,35 @@ sub as_xml { my $data; my $fh = IO::String->new(\$data); my $w = XML::Writer->new(OUTPUT => $fh, - DATA_MODE => 1, - DATA_INDENT => 2); + DATA_MODE => 1, + DATA_INDENT => 2); $w->startTag("network"); foreach (qw(name uuid)) { - $w->dataElement("$_" => $self->{$_}) if $self->{$_}; + $w->dataElement("$_" => $self->{$_}) if $self->{$_}; } $w->emptyTag("bridge", %{$self->{bridge}}) - if $self->{bridge}; + if $self->{bridge}; $w->emptyTag("forward", %{$self->{forward}}) - if exists $self->{forward}; + if exists $self->{forward}; if ($self->{ipaddr}) { - $w->startTag("ip", - address => $self->{ipaddr}->[0], - netmask => $self->{ipaddr}->[1]); - - if ($self->{dhcp}) { - $w->startTag("dhcp"); - foreach my $range (@{$self->{dhcp}}) { - $w->emptyTag("range", - start => $range->[0], - end => $range->[1]); - } - $w->endTag("dhcp"); - } - - $w->endTag("ip"); + $w->startTag("ip", + address => $self->{ipaddr}->[0], + netmask => $self->{ipaddr}->[1]); + + if ($self->{dhcp}) { + $w->startTag("dhcp"); + foreach my $range (@{$self->{dhcp}}) { + $w->emptyTag("range", + start => $range->[0], + end => $range->[1]); + } + $w->endTag("dhcp"); + } + + $w->endTag("ip"); } $w->endTag("network"); diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkHelpers.pm index f6bf8f9..5f563e5 100644 --- a/lib/Sys/Virt/TCK/NetworkHelpers.pm +++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm @@ -33,9 +33,9 @@ sub shutdown_vm_gracefully { my $target = time() + 30; $dom->shutdown; while ($dom->is_active()) { - sleep(1); - diag ".. waiting for virtual machine to shutdown.. "; - $dom->destroy() if time() > $target; + sleep(1); + diag ".. waiting for virtual machine to shutdown.. "; + $dom->destroy() if time() > $target; } sleep(1); diag ".. shutdown complete.. "; diff --git a/lib/Sys/Virt/TCK/SELinux.pm b/lib/Sys/Virt/TCK/SELinux.pm index c117fca..9f378a8 100644 --- a/lib/Sys/Virt/TCK/SELinux.pm +++ b/lib/Sys/Virt/TCK/SELinux.pm @@ -61,9 +61,9 @@ sub selinux_get_file_context { my @attr = split /\n/, `getfattr -n security.selinux $path 2>/dev/null`; foreach (@attr) { - if (/security.selinux=\"(.*)\"/) { - return $1; - } + if (/security.selinux=\"(.*)\"/) { + return $1; + } } return undef; } diff --git a/lib/Sys/Virt/TCK/StoragePoolBuilder.pm b/lib/Sys/Virt/TCK/StoragePoolBuilder.pm index 3973cd1..99b36ae 100644 --- a/lib/Sys/Virt/TCK/StoragePoolBuilder.pm +++ b/lib/Sys/Virt/TCK/StoragePoolBuilder.pm @@ -26,10 +26,10 @@ sub new { my %params = @_; my $self = { - name => $params{name} ? $params{name} : "tck" , - type => $params{type} ? $params{type} : "dir", - source => {}, - perms => {}, + name => $params{name} ? $params{name} : "tck" , + type => $params{type} ? $params{type} : "dir", + source => {}, + perms => {}, }; bless $self, $class; @@ -138,44 +138,44 @@ sub as_xml { my $data; my $fh = IO::String->new(\$data); my $w = XML::Writer->new(OUTPUT => $fh, - DATA_MODE => 1, - DATA_INDENT => 2); + DATA_MODE => 1, + DATA_INDENT => 2); $w->startTag("pool", type => $self->{type}); foreach (qw(name uuid)) { - $w->dataElement("$_" => $self->{$_}) if $self->{$_}; + $w->dataElement("$_" => $self->{$_}) if $self->{$_}; } $w->startTag("source"); if ($self->{source}->{host}) { - $w->emptyTag("host", name => $self->{source}->{host}); + $w->emptyTag("host", name => $self->{source}->{host}); } if ($self->{source}->{dir}) { - $w->emptyTag("dir", path => $self->{source}->{dir}); + $w->emptyTag("dir", path => $self->{source}->{dir}); } if ($self->{source}->{device}) { - foreach my $dev (@{$self->{source}->{device}}) { - $w->emptyTag("device", path => $dev); - } + foreach my $dev (@{$self->{source}->{device}}) { + $w->emptyTag("device", path => $dev); + } } if ($self->{source}->{adapter}) { - $w->emptyTag("adapter", name => $self->{source}->{adapter}); + $w->emptyTag("adapter", name => $self->{source}->{adapter}); } if ($self->{source}->{name}) { - $w->dataElement("name", $self->{source}->{name}); + $w->dataElement("name", $self->{source}->{name}); } if ($self->{format}) { - $w->emptyTag("format", type => $self->{format}); + $w->emptyTag("format", type => $self->{format}); } $w->endTag("source"); $w->startTag("target"); $w->dataElement("path", $self->{target}); if (int(keys %{$self->{perms}})) { - $w->startTag("permissions"); - foreach (qw(mode user group)) { - $w->dataElement("$_" => $self->{perms}->{$_}) if $self->{perms}->{$_}; - } - $w->endTag("permissions"); + $w->startTag("permissions"); + foreach (qw(mode user group)) { + $w->dataElement("$_" => $self->{perms}->{$_}) if $self->{perms}->{$_}; + } + $w->endTag("permissions"); } $w->endTag("target"); diff --git a/lib/Sys/Virt/TCK/StorageVolBuilder.pm b/lib/Sys/Virt/TCK/StorageVolBuilder.pm index da90788..7208f75 100644 --- a/lib/Sys/Virt/TCK/StorageVolBuilder.pm +++ b/lib/Sys/Virt/TCK/StorageVolBuilder.pm @@ -26,7 +26,7 @@ sub new { my %params = @_; my $self = { - name => $params{name} ? $params{name} : "tck" , + name => $params{name} ? $params{name} : "tck" , }; bless $self, $class; @@ -87,8 +87,8 @@ sub as_xml { my $data; my $fh = IO::String->new(\$data); my $w = XML::Writer->new(OUTPUT => $fh, - DATA_MODE => 1, - DATA_INDENT => 2); + DATA_MODE => 1, + DATA_INDENT => 2); $w->startTag("volume"); $w->dataElement("name" => $self->{name}); @@ -96,30 +96,30 @@ sub as_xml { $w->dataElement("allocation", $self->{allocation}); if ($self->{format} || $self->{secret}) { - $w->startTag("target"); - if ($self->{format}) { - $w->emptyTag("format", type => $self->{format}); - } - if ($self->{secret}) { - $w->startTag("encryption", format => "qcow"); - $w->emptyTag("secret", type => "passphrase", uuid => $self->{secret}); - $w->endTag("encryption"); - } - $w->endTag("target"); + $w->startTag("target"); + if ($self->{format}) { + $w->emptyTag("format", type => $self->{format}); + } + if ($self->{secret}) { + $w->startTag("encryption", format => "qcow"); + $w->emptyTag("secret", type => "passphrase", uuid => $self->{secret}); + $w->endTag("encryption"); + } + $w->endTag("target"); } if ($self->{backingFile}) { - $w->startTag("backingStore"); - $w->dataElement("path", $self->{backingFile}); - if ($self->{backingFormat}) { - $w->emptyTag("format", type => $self->{backingFormat}); - } - if ($self->{secret}) { - $w->startTag("encryption", format => "qcow"); - $w->emptyTag("secret", type => "passphrase", uuid => $self->{secret}); - $w->endTag("encryption"); - } - $w->endTag("backingStore"); + $w->startTag("backingStore"); + $w->dataElement("path", $self->{backingFile}); + if ($self->{backingFormat}) { + $w->emptyTag("format", type => $self->{backingFormat}); + } + if ($self->{secret}) { + $w->startTag("encryption", format => "qcow"); + $w->emptyTag("secret", type => "passphrase", uuid => $self->{secret}); + $w->endTag("encryption"); + } + $w->endTag("backingStore"); } $w->endTag("volume"); diff --git a/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm b/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm index b4514fd..a8fdf93 100644 --- a/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm +++ b/lib/Sys/Virt/TCK/TAP/XMLFormatter.pm @@ -35,8 +35,8 @@ sub _initialize { $self->verbosity(0); my $w = XML::Writer->new(OUTPUT => \*STDOUT, - DATA_MODE => 1, - DATA_INDENT => 2); + DATA_MODE => 1, + DATA_INDENT => 2); $self->xml($w); return $self; @@ -64,13 +64,13 @@ sub summary { my $agg = shift; $self->xml->startTag("summary", - total => int($agg->total), - passed => int($agg->passed), - failed => int($agg->failed), - todo => int($agg->todo), - unexpected => int($agg->todo_passed), - skipped => int($agg->skipped), - errors => int($agg->parse_errors)); + total => int($agg->total), + passed => int($agg->passed), + failed => int($agg->failed), + todo => int($agg->todo), + unexpected => int($agg->todo_passed), + skipped => int($agg->skipped), + errors => int($agg->parse_errors)); $self->xml->endTag("summary"); diff --git a/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm b/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm index ca2a298..cd4ba1b 100644 --- a/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm +++ b/lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm @@ -32,7 +32,7 @@ sub _initialize { $self->parser($args->{parser}); $self->xml->startTag("test", - name => $args->{test}); + name => $args->{test}); return $self; } @@ -45,7 +45,7 @@ sub result { my $meth = "result_" . $result->type; if ($self->can($meth)) { - $self->$meth($result); + $self->$meth($result); } } @@ -54,13 +54,13 @@ sub result_plan { my $result = shift; if ($result->has_skip) { - $self->xml->startTag("plan", - count => $result->tests_planned); - $self->xml->dataElement("skip", $result->explanation); - $self->xml->endTag("plan"); + $self->xml->startTag("plan", + count => $result->tests_planned); + $self->xml->dataElement("skip", $result->explanation); + $self->xml->endTag("plan"); } else { - $self->xml->emptyTag("plan", - count => $result->tests_planned); + $self->xml->emptyTag("plan", + count => $result->tests_planned); } } @@ -69,7 +69,7 @@ sub result_pragma { my $result = shift; foreach ($result->pragmas) { - $self->dataElement("pragma", $_); + $self->dataElement("pragma", $_); } } @@ -78,23 +78,23 @@ sub result_test { my $result = shift; $self->xml->startTag("test", - id => $result->number); + id => $result->number); if ($result->is_ok) { - $self->xml->emptyTag("pass"); + $self->xml->emptyTag("pass"); } else { - $self->xml->emptyTag("fail"); + $self->xml->emptyTag("fail"); } $self->xml->emptyTag("unplanned") if $result->is_unplanned; $self->xml->cdataElement("desc", $result->description); if ($result->has_todo) { - $self->xml->cdataElement("todo", $result->explanation, - pass => $result->todo_passed ? "yes" : "no"); + $self->xml->cdataElement("todo", $result->explanation, + pass => $result->todo_passed ? "yes" : "no"); } if ($result->has_skip) { - $self->xml->cdataElement("skip", $result->explanation); + $self->xml->cdataElement("skip", $result->explanation); } $self->xml->endTag("test"); @@ -105,7 +105,7 @@ sub result_bailout { my $result = shift; $self->xml->cdataElement("bailout", - $result->explanation); + $result->explanation); } sub result_version { @@ -144,31 +144,31 @@ sub close_test { my $self = shift; $self->xml->startTag("summary", - passed => int($self->parser->passed), - failed => int($self->parser->failed), - todo => int($self->parser->todo), - unexpected => int($self->parser->todo_passed), - skipped => int($self->parser->skipped)); + passed => int($self->parser->passed), + failed => int($self->parser->failed), + todo => int($self->parser->todo), + unexpected => int($self->parser->todo_passed), + skipped => int($self->parser->skipped)); if ($self->parser->skip_all) { - $self->xml->startTag("plan", - expected => int($self->parser->tests_planned), - actual => int($self->parser->tests_run)); - $self->xml->cdataElement("skip", $self->parser->skip_all); - $self->xml->endTag("plan"); + $self->xml->startTag("plan", + expected => int($self->parser->tests_planned), + actual => int($self->parser->tests_run)); + $self->xml->cdataElement("skip", $self->parser->skip_all); + $self->xml->endTag("plan"); } else { - $self->xml->emptyTag("plan", - expected => int($self->parser->tests_planned), - actual => int($self->parser->tests_run)); + $self->xml->emptyTag("plan", + expected => int($self->parser->tests_planned), + actual => int($self->parser->tests_run)); } $self->xml->emptyTag("status", - wait => $self->parser->wait, - exit => $self->parser->exit); + wait => $self->parser->wait, + exit => $self->parser->exit); $self->xml->emptyTag("timing", - start => $self->parser->start_time, - end => $self->parser->end_time); + start => $self->parser->start_time, + end => $self->parser->end_time); $self->xml->endTag("summary"); diff --git a/scripts/nwfilter/300-vsitype.t b/scripts/nwfilter/300-vsitype.t index d169339..90d237f 100644 --- a/scripts/nwfilter/300-vsitype.t +++ b/scripts/nwfilter/300-vsitype.t @@ -52,7 +52,7 @@ if ( ! -e '/usr/sbin/lldptool' ) { # create first domain and start it my $xml = $tck->generic_domain(name => "tck", fullos => 1, - netmode => "vepa")->as_xml(); + netmode => "vepa")->as_xml(); my $dom; ok_domain(sub { $dom = $conn->define_domain($xml) }, "created persistent domain object"); diff --git a/scripts/nwfilter/concurrency/chg-vm-filter.sh b/scripts/nwfilter/concurrency/chg-vm-filter.sh index 3cf26ee..3066f59 100644 --- a/scripts/nwfilter/concurrency/chg-vm-filter.sh +++ b/scripts/nwfilter/concurrency/chg-vm-filter.sh @@ -1,7 +1,7 @@ #!/bin/sh cleanup() { - virsh nwfilter-undefine tck-vm${idx}-filter 2>/dev/null + virsh nwfilter-undefine tck-vm${idx}-filter 2>/dev/null } cd $(dirname "$0") @@ -16,14 +16,14 @@ trap cleanup 2 while :; do - virsh nwfilter-define tck-vm${idx}-filter1.xml - [ $? -ne 0 ] && break - [ ! -w "${logfile}" ] && break - virsh nwfilter-define tck-vm${idx}-filter2.xml - [ $? -ne 0 ] && break - ctr=$(($ctr + 1)) - [ ! -w "${logfile}" ] && break - echo "${ctr}" >> "${logfile}" + virsh nwfilter-define tck-vm${idx}-filter1.xml + [ $? -ne 0 ] && break + [ ! -w "${logfile}" ] && break + virsh nwfilter-define tck-vm${idx}-filter2.xml + [ $? -ne 0 ] && break + ctr=$(($ctr + 1)) + [ ! -w "${logfile}" ] && break + echo "${ctr}" >> "${logfile}" done cleanup diff --git a/scripts/nwfilter/concurrency/start-destroy-vm.sh b/scripts/nwfilter/concurrency/start-destroy-vm.sh index 9e94708..0662997 100644 --- a/scripts/nwfilter/concurrency/start-destroy-vm.sh +++ b/scripts/nwfilter/concurrency/start-destroy-vm.sh @@ -2,8 +2,8 @@ cleanup() { - virsh destroy tck-vm${idx} 2>/dev/null - virsh nwfilter-undefine tck-vm${idx}-filter 2>/dev/null + virsh destroy tck-vm${idx} 2>/dev/null + virsh nwfilter-undefine tck-vm${idx}-filter 2>/dev/null } cd $(dirname "$0") @@ -18,14 +18,14 @@ trap cleanup 2 while :; do - virsh create tck-vm${idx}.xml - [ $? -ne 0 ] && break - sleep 2 - virsh destroy tck-vm${idx} - [ $? -ne 0 ] && break - ctr=$(($ctr + 1)) - [ ! -w "${logfile}" ] && break - echo "${ctr}" >> "${logfile}" + virsh create tck-vm${idx}.xml + [ $? -ne 0 ] && break + sleep 2 + virsh destroy tck-vm${idx} + [ $? -ne 0 ] && break + ctr=$(($ctr + 1)) + [ ! -w "${logfile}" ] && break + echo "${ctr}" >> "${logfile}" done cleanup diff --git a/scripts/nwfilter/nwfilter2vmtest.sh b/scripts/nwfilter/nwfilter2vmtest.sh index 4cf63b2..90a5255 100644 --- a/scripts/nwfilter/nwfilter2vmtest.sh +++ b/scripts/nwfilter/nwfilter2vmtest.sh @@ -139,7 +139,7 @@ checkExpectedOutput() { skip=0 if [ "x${skipregex}x" != "xx" ]; then - skip=$(printf %s\\n ${cmd} | grep -c -E ${skipregex}) + skip=$(printf %s\\n ${cmd} | grep -c -E ${skipregex}) fi eval ${cmd} 2>&1 | tee ${tmpfile} 1>/dev/null @@ -157,12 +157,12 @@ checkExpectedOutput() { if [ "x${letter}x" = "x#x" ] || [ "x${line}x" = "xx" ]; then - if [ ${skip} -ne 0 ]; then - break - fi + if [ ${skip} -ne 0 ]; then + break + fi - if [ -n "${skiptest}" ]; then - # treat all skips as passes + if [ -n "${skiptest}" ]; then + # treat all skips as passes passctr=$(($passctr + 1)) [ $(($flags & $FLAG_VERBOSE)) -ne 0 ] && \ echo "SKIP ${xmlfile} : ${cmd}" @@ -171,7 +171,7 @@ checkExpectedOutput() { [ $(($flags & $FLAG_TAP_TEST)) -ne 0 ] && \ tap_pass $(($passctr + $failctr)) "SKIP: ${xmlfile} : ${skiptest}" break - fi + fi if [ $IPTABLES_CTDIR_CORRECTED -ne 0 ]; then #change --ctdir ORIGINAL to --ctdir REPLY @@ -196,8 +196,8 @@ checkExpectedOutput() { failctr=$(($failctr + 1)) if [ $(($flags & $FLAG_WAIT)) -ne 0 ]; then echo "tmp files: $tmpfile, $tmpfile2" - echo "Press enter" - read enter + echo "Press enter" + read enter fi [ $(($flags & $FLAG_LIBVIRT_TEST)) -ne 0 ] && \ test_result $(($passctr + $failctr)) "" 1 @@ -239,15 +239,15 @@ doTest() { skiptest="" if [ ! -r "${xmlfile}" ]; then - echo "FAIL : Cannot access filter XML file ${xmlfile}." - return 1 + echo "FAIL : Cannot access filter XML file ${xmlfile}." + return 1 fi # Check whether we can run this test at all cmd=$(sed -n '1 s/^<\!--[ ]*#\(.*\)#[ ]*-->/\1/p' "${xmlfile}") if [ -n "${cmd}" ]; then - eval "${cmd}" 2>/dev/null 1>/dev/null - [ $? -ne 0 ] && skiptest="${cmd}" + eval "${cmd}" 2>/dev/null 1>/dev/null + [ $? -ne 0 ] && skiptest="${cmd}" fi [ -z "${skiptest}" ] && ${VIRSH} nwfilter-define "${xmlfile}" > /dev/null @@ -643,23 +643,23 @@ main() { createTestFilters "${flags}" if [ $? -ne 0 ]; then - exit 1; + exit 1; fi createVM "${vm1}" "tck-testcase" "10.2.2.2" "52:54:0:0:0:1" "${flags}" if [ $? -ne 0 ]; then - echo "Could not create VM ${vm1}. Exiting." - deleteTestFilter "${flags}" - exit 1 + echo "Could not create VM ${vm1}. Exiting." + deleteTestFilter "${flags}" + exit 1 fi createVM "${vm2}" "${TESTFILTERNAME}" "10.1.1.1" "52:54:0:9f:33:da" \ "${flags}" if [ $? -ne 0 ]; then - echo "Could not create VM ${vm2}. Exiting." - destroyVM "${vm1}" "${flags}" - deleteTestFilter "${flags}" - exit 1 + echo "Could not create VM ${vm2}. Exiting." + destroyVM "${vm1}" "${flags}" + deleteTestFilter "${flags}" + exit 1 fi runTests "${vm1}" "${vm2}" "${xmldir}" "${fwalldir}" "${flags}" -- 2.14.3

On 02/08/2018 02:19 PM, Laine Stump wrote:
verified that only tabs were removed by running "git diff -w".
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

On Thu, Feb 08, 2018 at 02:19:39PM -0500, Laine Stump wrote:
verified that only tabs were removed by running "git diff -w".
Signed-off-by: Laine Stump <laine@laine.org> --- lib/Sys/Virt/TCK.pm | 544 +++++++++++------------ lib/Sys/Virt/TCK/Capabilities.pm | 84 ++-- lib/Sys/Virt/TCK/DomainBuilder.pm | 312 ++++++------- lib/Sys/Virt/TCK/NetworkBuilder.pm | 44 +- lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 +- lib/Sys/Virt/TCK/SELinux.pm | 6 +- lib/Sys/Virt/TCK/StoragePoolBuilder.pm | 40 +- lib/Sys/Virt/TCK/StorageVolBuilder.pm | 48 +- lib/Sys/Virt/TCK/TAP/XMLFormatter.pm | 18 +- lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm | 66 +-- scripts/nwfilter/300-vsitype.t | 2 +- scripts/nwfilter/concurrency/chg-vm-filter.sh | 18 +- scripts/nwfilter/concurrency/start-destroy-vm.sh | 20 +- scripts/nwfilter/nwfilter2vmtest.sh | 42 +- 14 files changed, 625 insertions(+), 625 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 02/08/2018 02:19 PM, Laine Stump wrote:
I've pushed the patches that passed review. These patches split a single patch from V1 into 2 patches, repost one patch that had no response, calls out a single line that had sneaked into one of the ACKed patches, and remove all tabs from perl and sh scripts.
Laine Stump (5): parameterize filterref in generic_domain default to no nwfilter in test domains filter for proper IP address in tcpdump looking for broadcast packet kill dhclient before attempting to change guest IP in no-ip-spoofing test untabify all perl and sh files
lib/Sys/Virt/TCK.pm | 549 ++++++++++++----------- lib/Sys/Virt/TCK/Capabilities.pm | 84 ++-- lib/Sys/Virt/TCK/DomainBuilder.pm | 312 ++++++------- lib/Sys/Virt/TCK/NetworkBuilder.pm | 44 +- lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 +- lib/Sys/Virt/TCK/SELinux.pm | 6 +- lib/Sys/Virt/TCK/StoragePoolBuilder.pm | 40 +- lib/Sys/Virt/TCK/StorageVolBuilder.pm | 48 +- lib/Sys/Virt/TCK/TAP/XMLFormatter.pm | 18 +- lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm | 66 +-- scripts/nwfilter/100-ping-still-working.t | 3 +- scripts/nwfilter/210-no-mac-spoofing.t | 3 +- scripts/nwfilter/220-no-ip-spoofing.t | 4 +- scripts/nwfilter/230-no-mac-broadcast.t | 5 +- scripts/nwfilter/240-no-arp-spoofing.t | 3 +- scripts/nwfilter/300-vsitype.t | 2 +- scripts/nwfilter/concurrency/chg-vm-filter.sh | 18 +- scripts/nwfilter/concurrency/start-destroy-vm.sh | 20 +- scripts/nwfilter/nwfilter2vmtest.sh | 42 +- 19 files changed, 641 insertions(+), 632 deletions(-)
FWIW: This and the patches already pushed works great in my test environment with the onlist nwfilter patches also applied. Very entertaining and educational to watch with --verbose flag set too. The only one that I'm not sure how to configure to make sure it runs is the 300-vsitype.t - here's the tail end of my output: /usr/share/libvirt-tck/tests/nwfilter/300-vsitype.t ............. 1..0 # SKIP no host net device configured skipped: no host net device configured All tests successful. Files=8, Tests=1272, 376 wallclock secs ( 0.59 usr 0.06 sys + 36.76 cusr 54.68 csys = 92.09 CPU) Result: PASS John

On Fri, Feb 09, 2018 at 08:12:15AM -0500, John Ferlan wrote:
On 02/08/2018 02:19 PM, Laine Stump wrote:
I've pushed the patches that passed review. These patches split a single patch from V1 into 2 patches, repost one patch that had no response, calls out a single line that had sneaked into one of the ACKed patches, and remove all tabs from perl and sh scripts.
Laine Stump (5): parameterize filterref in generic_domain default to no nwfilter in test domains filter for proper IP address in tcpdump looking for broadcast packet kill dhclient before attempting to change guest IP in no-ip-spoofing test untabify all perl and sh files
lib/Sys/Virt/TCK.pm | 549 ++++++++++++----------- lib/Sys/Virt/TCK/Capabilities.pm | 84 ++-- lib/Sys/Virt/TCK/DomainBuilder.pm | 312 ++++++------- lib/Sys/Virt/TCK/NetworkBuilder.pm | 44 +- lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 +- lib/Sys/Virt/TCK/SELinux.pm | 6 +- lib/Sys/Virt/TCK/StoragePoolBuilder.pm | 40 +- lib/Sys/Virt/TCK/StorageVolBuilder.pm | 48 +- lib/Sys/Virt/TCK/TAP/XMLFormatter.pm | 18 +- lib/Sys/Virt/TCK/TAP/XMLFormatterSession.pm | 66 +-- scripts/nwfilter/100-ping-still-working.t | 3 +- scripts/nwfilter/210-no-mac-spoofing.t | 3 +- scripts/nwfilter/220-no-ip-spoofing.t | 4 +- scripts/nwfilter/230-no-mac-broadcast.t | 5 +- scripts/nwfilter/240-no-arp-spoofing.t | 3 +- scripts/nwfilter/300-vsitype.t | 2 +- scripts/nwfilter/concurrency/chg-vm-filter.sh | 18 +- scripts/nwfilter/concurrency/start-destroy-vm.sh | 20 +- scripts/nwfilter/nwfilter2vmtest.sh | 42 +- 19 files changed, 641 insertions(+), 632 deletions(-)
FWIW: This and the patches already pushed works great in my test environment with the onlist nwfilter patches also applied. Very entertaining and educational to watch with --verbose flag set too.
The only one that I'm not sure how to configure to make sure it runs is the 300-vsitype.t - here's the tail end of my output:
/usr/share/libvirt-tck/tests/nwfilter/300-vsitype.t ............. 1..0 # SKIP no host net device configured skipped: no host net device configured
You need to edit the libvirt-tck.cfg file and set "host_network_devices" to contain a physical NIC that it can mess around with. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (4)
-
Daniel P. Berrangé
-
John Ferlan
-
Laine Stump
-
Stefan Berger