From: Richard Jones Date: Thu, 1 Oct 2009 14:20:14 +0000 (+0100) Subject: inspector: Don't bomb if no kernels detected. X-Git-Tag: 1.0.73~12 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=5021b2efea92c021c04812056149485ac4803e9c;p=libguestfs.git inspector: Don't bomb if no kernels detected. If $os->{kernels} wasn't defined, virt-inspector would exit with an error, leaving partial XML output. Change the code so it doesn't die in this case, instead just leaves out the section. --- diff --git a/inspector/virt-inspector b/inspector/virt-inspector index 86b1795..dc8847f 100755 --- a/inspector/virt-inspector +++ b/inspector/virt-inspector @@ -550,23 +550,25 @@ sub output_xml_os $xml->endTag("boot"); } - $xml->startTag("kernels"); - my @kernels = @{$os->{kernels}}; - foreach (@kernels) { - $xml->startTag("kernel", - "version" => $_->{version}, - "arch" => $_->{arch}); - $xml->startTag("modules"); - my @modules = @{$_->{modules}}; - foreach (@modules) { - $xml->dataElement("module", $_); - } - $xml->endTag("modules"); - $xml->dataElement("path", $_->{path}) if(defined($_->{path})); - $xml->dataElement("package", $_->{package}) if(defined($_->{package})); - $xml->endTag("kernel"); + if ($os->{kernels}) { + $xml->startTag("kernels"); + my @kernels = @{$os->{kernels}}; + foreach (@kernels) { + $xml->startTag("kernel", + "version" => $_->{version}, + "arch" => $_->{arch}); + $xml->startTag("modules"); + my @modules = @{$_->{modules}}; + foreach (@modules) { + $xml->dataElement("module", $_); + } + $xml->endTag("modules"); + $xml->dataElement("path", $_->{path}) if(defined($_->{path})); + $xml->dataElement("package", $_->{package}) if(defined($_->{package})); + $xml->endTag("kernel"); + } + $xml->endTag("kernels"); } - $xml->endTag("kernels"); if (exists $os->{root}->{registry}) { $xml->startTag("windowsregistryentries");