diff options
author | Matthew Booth <mbooth@redhat.com> | 2009-06-25 17:19:29 +0100 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2009-06-25 17:19:29 +0100 |
commit | 247225c4415b28d02a82b7fc4dfdd35728437711 (patch) | |
tree | 743f20d02132265c14bb6102e8ea4124c5a062df /inspector | |
parent | 7ca3e5b08ae6e6f062b5065475ffb07cb08a7610 (diff) | |
download | libguestfs-247225c4415b28d02a82b7fc4dfdd35728437711.tar.gz libguestfs-247225c4415b28d02a82b7fc4dfdd35728437711.tar.xz libguestfs-247225c4415b28d02a82b7fc4dfdd35728437711.zip |
Make virt-inspector look in more places for module aliases
Specifically:
/etc/conf.modules
/etc/modules.conf
/etc/modprobe.conf
/etc/modprobe.d/*
Diffstat (limited to 'inspector')
-rwxr-xr-x | inspector/virt-inspector.pl | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl index fc9b68e3..8417675e 100755 --- a/inspector/virt-inspector.pl +++ b/inspector/virt-inspector.pl @@ -844,14 +844,47 @@ sub check_for_modprobe_aliases local $_; my $root_dev = shift; - my @lines; - eval { @lines = $g->read_lines ("/etc/modprobe.conf"); }; - return if $@ || !@lines; + # Initialise augeas + my $success = 0; + $success = $g->aug_init("/", 16); + + # Register /etc/modules.conf and /etc/conf.modules to the Modprobe lens + my @results; + @results = $g->aug_match("/augeas/load/Modprobe/incl"); + + # Calculate the next index of /augeas/load/Modprobe/incl + my $i = 1; + foreach ( @results ) { + next unless m{/augeas/load/Modprobe/incl\[(\d*)]}; + $i = $1 + 1 if ($1 == $i); + } + + $success = $g->aug_set("/augeas/load/Modprobe/incl[$i]", + "/etc/modules.conf"); + $i++; + $success = $g->aug_set("/augeas/load/Modprobe/incl[$i]", + "/etc/conf.modules"); + + # Make augeas reload + $success = $g->aug_load(); my %modprobe_aliases; - foreach (@lines) { - $modprobe_aliases{$1} = $2 if /^\s*alias\s+(\S+)\s+(\S+)/; + for my $pattern qw(/files/etc/conf.modules/alias + /files/etc/modules.conf/alias + /files/etc/modprobe.conf/alias + /files/etc/modprobe.d/*/alias) { + @results = $g->aug_match($pattern); + + for my $path ( @results ) { + my $alias; + $alias = $g->aug_get($path); + + my $modulename; + $modulename = $g->aug_get($path.'/modulename'); + + $modprobe_aliases{$alias} = $modulename; + } } $oses{$root_dev}->{modprobe_aliases} = \%modprobe_aliases; |