On 23/02/10 19:42, Guido Günther wrote:
>From d30b4946f017ff8bde9d4ff62f93c418a707d9e8 Mon Sep 17 00:00:00
2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx(a)sigxcpu.org>
Date: Tue, 23 Feb 2010 19:50:40 +0100
Subject: [PATCH] Check for grub/menu.lst if /etc/grub.conf can't be found
In virt-v2v, I actually don't bother looking for /etc/grub.conf, and
always use /boot/grub/menu.lst because it's symlinked on Red Hat systems.
---
perl/lib/Sys/Guestfs/Lib.pm | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index e17728d..2864bfa 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1525,6 +1525,12 @@ sub _check_for_kernels
# For every kernel we find, inspect it and add to $os->{kernels}
my $grub = _find_grub_prefix($g, $os);
+ my $grub_conf = "/etc/grub.conf";
+
+ # Debian and other's have no /etc/grub.conf:
+ if ( ! -f "$grub_conf" ) {
+ $grub_conf = "$grub/grub/menu.lst";
+ }
my @boot_configs;
@@ -1544,7 +1550,7 @@ sub _check_for_kernels
my @configs = ();
# Get all configurations from grub
foreach my $bootable
- ($g->aug_match("/files/etc/grub.conf/title"))
+ ($g->aug_match("/files/$grub_conf/title"))
{
my %config = ();
$config{title} = $g->aug_get($bootable);
@@ -1617,7 +1623,7 @@ sub _check_for_kernels
# Add the default configuration
eval {
- $boot{default} = $g->aug_get("/files/etc/grub.conf/default");
+ $boot{default} = $g->aug_get("/files/$grub_conf/default");
Not convinced the above will work reliably, because augeas (at least not
as distributed by Fedora) doesn't load menu.lst by default. Have a look
here for how I did this in virt-v2v:
http://git.fedoraproject.org/git/virt-v2v.git?p=virt-v2v.git;a=blob;f=lib...
If Debian change the grub config in augeas to load menu.lst instead of
grub.conf, this would mean that a Fedora machine would only be able to
find kernels on Fedora guests, and a Debian machine would only be able
to find kernels on a Debian guest.
Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team
M: +44 (0)7977 267231
GPG ID: D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490