>From 5021b2efea92c021c04812056149485ac4803e9c Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 1 Oct 2009 15:20:14 +0100 Subject: [PATCH 1/2] 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. --- inspector/virt-inspector | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-) 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"); -- 1.6.2.5