[libvirt] [tck PATCH 1/2] cleanup all nwfilters beginning with ^tck

Laine Stump laine at laine.org
Tue Mar 6 17:56:46 UTC 2018


Just as we do with domains, network, etc, do a pre-test check for any
existing nwfilters that start with "tck" (the test will be aborted in
that case unless "--force" is added to the commandline), and remove
same during the cleanup at the end.

Signed-off-by: Laine Stump <laine at laine.org>
---
 lib/Sys/Virt/TCK.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index f9d9f30..e7ff71b 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -130,6 +130,11 @@ sub sanity_check {
         die "there is/are " . int(@nets) . " pre-existing inactive network(s) in this driver";
     }
 
+    my @nwfilters = grep { $_->get_name =~ /^tck/ } $conn->list_nwfilters;
+    if (@nwfilters) {
+        die "there is/are " . int(@nwfilters) . " pre-existing nwfilter(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";
@@ -188,6 +193,16 @@ sub reset_networks {
     }
 }
 
+sub reset_nwfilters {
+    my $self = shift;
+    my $conn = shift;
+
+    my @nwfilters = grep { $_->get_name =~ /^tck/ } $conn->list_nwfilters;
+    foreach my $nwfilter (@nwfilters) {
+        $nwfilter->undefine;
+    }
+}
+
 sub reset_storage_pools {
     my $self = shift;
     my $conn = shift;
@@ -217,6 +232,7 @@ sub reset {
 
     $self->reset_domains($conn);
     $self->reset_networks($conn);
+    $self->reset_nwfilters($conn);
     $self->reset_storage_pools($conn);
 }
 
-- 
2.14.3




More information about the libvir-list mailing list