[PATCH] inspector: Don't bomb if no kernels detected.
This is a partial fix for https://bugzilla.redhat.com/show_bug.cgi?id=526717 Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
Richard W.M. Jones wrote:
This is a partial fix for https://bugzilla.redhat.com/show_bug.cgi?id=526717 ... 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 <kernels> 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}) { ...<indented-code-elided>... + $xml->endTag("kernels"); } - $xml->endTag("kernels");
if (exists $os->{root}->{registry}) { $xml->startTag("windowsregistryentries");
ACK. That will definitely result in better output.
participants (2)
-
Jim Meyering -
Richard W.M. Jones