From nobody Sun May 5 13:55:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528120613817593.9512766912198; Mon, 4 Jun 2018 06:56:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B14930BA30B; Mon, 4 Jun 2018 13:56:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 236CD608F0; Mon, 4 Jun 2018 13:56:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 040741808872; Mon, 4 Jun 2018 13:56:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w54Dqwl0001899 for ; Mon, 4 Jun 2018 09:52:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 461D120292A8; Mon, 4 Jun 2018 13:52:58 +0000 (UTC) Received: from vhost2.laine.org (ovpn-117-50.phx2.redhat.com [10.3.117.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF8552017D01; Mon, 4 Jun 2018 13:52:57 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Mon, 4 Jun 2018 09:52:52 -0400 Message-Id: <20180604135252.417917-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [tck PATCH] Don't assume the domain's network interface tap device is named "vnet0" X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 04 Jun 2018 13:56:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some of the tests perform operations on the tap device of the test domain's network interface. They mostly assume that this tap device is named "vnet0", which is the case if there is no other domain running on the host, but isn't true if some other domain was running. This patch adds a utility function NetworkHelpers::get_first_interface_target_dev($dom), which learns the name of the tap device for the first interface in the domain, and uses the result of that function instead of "vnet0". It's an ugly name, but follows the pattern of other function names in that file. It also is very specific (it could have been parameterized to get the tap device name of other interfaces, but we only ever need the first). On the other hand, it causes the tests in question to succeed on my host when they previously failed. (If anyone wants the function to be named differently or be more flexible, I'd be happy to do that). Signed-off-by: Laine Stump Reviewed-by: Daniel P. Berrang=C3=A9 --- lib/Sys/Virt/TCK.pm | 3 ++- lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 ++++++ scripts/domain/180-interface-parameters.t | 6 ++++-- scripts/nwfilter/100-ping-still-working.t | 3 ++- scripts/nwfilter/210-no-mac-spoofing.t | 3 ++- scripts/nwfilter/230-no-mac-broadcast.t | 3 ++- scripts/nwfilter/240-no-arp-spoofing.t | 3 ++- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index ac9c125..29280f6 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -821,11 +821,12 @@ sub generic_machine_domain { $dom->create(); =20 # Wait for the first boot to reach network setting + my $iface =3D get_first_interface_target_dev($dom); my $stats; my $tries =3D 0; do { sleep(10); - $stats =3D $dom->interface_stats("vnet0"); + $stats =3D $dom->interface_stats($iface); $tries++; } while ($stats->{"tx_packets"} < 10 && $tries < 10); =20 diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkH= elpers.pm index 7bbce62..50ade0f 100644 --- a/lib/Sys/Virt/TCK/NetworkHelpers.pm +++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm @@ -10,6 +10,12 @@ sub get_first_macaddress { return $mac; } =20 +sub get_first_interface_target_dev { + my $dom =3D shift; + my $targetdev =3D xpath($dom, "string(/domain/devices/interface[1]/tar= get/\@dev)"); + return $targetdev; +} + sub get_network_ip { my $conn =3D shift; my $netname =3D shift; diff --git a/scripts/domain/180-interface-parameters.t b/scripts/domain/180= -interface-parameters.t index d7866c0..66c7ed6 100644 --- a/scripts/domain/180-interface-parameters.t +++ b/scripts/domain/180-interface-parameters.t @@ -33,6 +33,7 @@ use warnings; use Test::More tests =3D> 10; =20 use Sys::Virt::TCK; +use Sys::Virt::TCK::NetworkHelpers; use Test::Exception; use File::stat; =20 @@ -59,12 +60,13 @@ diag "Set/Get interface parameters"; my %params =3D (Sys::Virt::Domain::BANDWIDTH_IN_AVERAGE=3D>1000, Sys::Virt= ::Domain::BANDWIDTH_IN_PEAK=3D>1001, Sys::Virt::Domain::BANDWIDTH_IN_BURST=3D>1002, Sys::Virt::Do= main::BANDWIDTH_OUT_AVERAGE=3D>1003, Sys::Virt::Domain::BANDWIDTH_OUT_PEAK=3D>1004, Sys::Virt::Do= main::BANDWIDTH_OUT_BURST=3D>1005); -lives_ok(sub {$dom->set_interface_parameters("vnet0", \%params)}, "Set vne= t0 parameters"); +my $iface =3D get_first_interface_target_dev($dom); +lives_ok(sub {$dom->set_interface_parameters($iface, \%params)}, "Set $ifa= ce parameters"); for my $key (sort keys %params) { diag "Set $key =3D> $params{$key} "; } =20 -my $param =3D $dom->get_interface_parameters("vnet0", 0); +my $param =3D $dom->get_interface_parameters($iface, 0); my $in_average =3D $param->{Sys::Virt::Domain::BANDWIDTH_IN_AVERAGE}; my $in_burst =3D $param->{Sys::Virt::Domain::BANDWIDTH_IN_BURST}; my $in_peak =3D $param->{Sys::Virt::Domain::BANDWIDTH_IN_PEAK}; diff --git a/scripts/nwfilter/100-ping-still-working.t b/scripts/nwfilter/1= 00-ping-still-working.t index 1bbd7c5..12f2c7c 100644 --- a/scripts/nwfilter/100-ping-still-working.t +++ b/scripts/nwfilter/100-ping-still-working.t @@ -55,11 +55,12 @@ $dom->create; ok($dom->get_id() > 0, "running domain has an ID > 0"); =20 diag "Waiting for guest to finish booting"; +my $iface =3D get_first_interface_target_dev($dom); my $stats; my $tries =3D 0; do { sleep(10); - $stats =3D $dom->interface_stats("vnet0"); + $stats =3D $dom->interface_stats($iface); $tries++; } while ($stats->{"tx_packets"} < 10 && $tries < 10); =20 diff --git a/scripts/nwfilter/210-no-mac-spoofing.t b/scripts/nwfilter/210-= no-mac-spoofing.t index 7b74f94..99c5058 100644 --- a/scripts/nwfilter/210-no-mac-spoofing.t +++ b/scripts/nwfilter/210-no-mac-spoofing.t @@ -59,11 +59,12 @@ $dom->create; ok($dom->get_id() > 0, "running domain has an ID > 0"); =20 diag "Waiting for guest to finish booting"; +my $iface =3D get_first_interface_target_dev($dom); my $stats; my $tries =3D 0; do { sleep(10); - $stats =3D $dom->interface_stats("vnet0"); + $stats =3D $dom->interface_stats($iface); $tries++; } while ($stats->{"tx_packets"} < 10 && $tries < 10); =20 diff --git a/scripts/nwfilter/230-no-mac-broadcast.t b/scripts/nwfilter/230= -no-mac-broadcast.t index ee2d43f..b65b3fc 100644 --- a/scripts/nwfilter/230-no-mac-broadcast.t +++ b/scripts/nwfilter/230-no-mac-broadcast.t @@ -85,11 +85,12 @@ $dom->create; ok($dom->get_id() > 0, "running domain has an ID > 0"); =20 diag "Waiting for guest to finish booting"; +my $iface =3D get_first_interface_target_dev($dom); my $stats; my $tries =3D 0; do { sleep(10); - $stats =3D $dom->interface_stats("vnet0"); + $stats =3D $dom->interface_stats($iface); $tries++; } while ($stats->{"tx_packets"} < 10 && $tries < 10); =20 diff --git a/scripts/nwfilter/240-no-arp-spoofing.t b/scripts/nwfilter/240-= no-arp-spoofing.t index 350b604..69851b6 100644 --- a/scripts/nwfilter/240-no-arp-spoofing.t +++ b/scripts/nwfilter/240-no-arp-spoofing.t @@ -58,11 +58,12 @@ $dom->create; ok($dom->get_id() > 0, "running domain has an ID > 0"); =20 diag "Waiting for guest to finish booting"; +my $iface =3D get_first_interface_target_dev($dom); my $stats; my $tries =3D 0; do { sleep(10); - $stats =3D $dom->interface_stats("vnet0"); + $stats =3D $dom->interface_stats($iface); $tries++; } while ($stats->{"tx_packets"} < 10 && $tries < 10); =20 --=20 2.14.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list