[libvirt] [PATCH tck 4/5] Ensure uri_transport is defined before using it

Mike Latimer mlatimer at suse.com
Mon Jan 26 22:06:52 UTC 2015


Under some environments (such as Xen), there may not be a uri_transport
defined. As this is not required, ensure the value is defined before
attempting to use it


---
 lib/Sys/Virt/TCK/Capabilities.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/Sys/Virt/TCK/Capabilities.pm b/lib/Sys/Virt/TCK/Capabilities.pm
index 8b79db4..281f41e 100644
--- a/lib/Sys/Virt/TCK/Capabilities.pm
+++ b/lib/Sys/Virt/TCK/Capabilities.pm
@@ -115,8 +115,10 @@ sub _parse_host_migration {
 
     $mig->{transports} = [];
     my $trans = $node->first_child("uri_transports");
-    foreach my $child ($trans->children("uri_transport")) {
-	push @{$mig->{transports}}, $child->text;
+    if (defined $trans) {
+	foreach my $child ($trans->children("uri_transport")) {
+	    push @{$mig->{transports}}, $child->text;
+	}
     }
 
     $self->{host}->{migration} = $mig;
-- 
1.8.4.5




More information about the libvir-list mailing list