diff options
author | Matthew Booth <mbooth@redhat.com> | 2009-07-31 17:31:54 +0100 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2009-08-03 11:40:42 +0100 |
commit | e2fa1fe4efcb3bbfe5b7cc2e98b10357abb59422 (patch) | |
tree | 2af88632ffa58435b238278c962c100dc72c4bab /inspector | |
parent | 1ba754119a43c4dd715d2e0a4637e50e10ac6987 (diff) | |
download | libguestfs-e2fa1fe4efcb3bbfe5b7cc2e98b10357abb59422.tar.gz libguestfs-e2fa1fe4efcb3bbfe5b7cc2e98b10357abb59422.tar.xz libguestfs-e2fa1fe4efcb3bbfe5b7cc2e98b10357abb59422.zip |
Use grub entries to find Linux kernels
This change adds grub parsing to Lib.pm. It adds the following structure to $os:
{boot}
->{configs}
->[0]
->{title} = "Fedora (2.6.29.6-213.fc11.i686.PAE)"
->{kernel} = \kernel
->{cmdline} = "ro root=/dev/mapper/vg_mbooth-lv_root rhgb"
->{initrd} = \initrd
->{default} = 0
The kernel and initrd entries are just references to their top level entries
under kernels and initrd_modules respectively.
It also changes the way Linux kernels and initrd are discovered. Instead of
searching /lib/modules and /boot for files with matching names, kernels and
initrds are scanned as they are discovered in grub.conf.
Additionally, the following attributes are added to the kernels top level entry:
* path
The path to the kernel's vmlinuz file.
* package
The name of the package which installed the kernel.
The xml output of virt-inspector is updated to reflect all of the above changes.
Diffstat (limited to 'inspector')
-rwxr-xr-x | inspector/virt-inspector.pl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl index d2acf062..17c63759 100755 --- a/inspector/virt-inspector.pl +++ b/inspector/virt-inspector.pl @@ -530,6 +530,27 @@ sub output_xml_os } $xml->endTag("applications"); + if(defined($os->{boot}) && defined($os->{boot}->{configs})) { + my $default = $os->{boot}->{default}; + my $configs = $os->{boot}->{configs}; + + $xml->startTag("boot"); + for(my $i = 0; $i < scalar(@$configs); $i++) { + my $config = $configs->[$i]; + + my @attrs = (); + push(@attrs, ("default" => 1)) if($default == $i); + $xml->startTag("config", @attrs); + $xml->dataElement("title", $config->{title}); + $xml->dataElement("kernel", $config->{kernel}->{version}) + if(defined($config->{kernel})); + $xml->dataElement("cmdline", $config->{cmdline}) + if(defined($config->{cmdline})); + $xml->endTag("config"); + } + $xml->endTag("boot"); + } + $xml->startTag("kernels"); my @kernels = @{$os->{kernels}}; foreach (@kernels) { @@ -542,6 +563,8 @@ sub output_xml_os $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"); |