[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] Rely on new augeas lens for modules.conf and conf.modules



We were previously forcing the augeas Modprobe lens to match modules.conf and
conf.modules. It turns out that the contents of these files are quite different
to modprobe.conf, requiring a new lens.

This change keeps the logic which looks for where modules should go, but doesn't
update the augeas configuration. If there is no augeas lens for
/etc/modules.conf, any attempt to parse or modify it will fail.
---
 lib/Sys/VirtV2V/GuestOS/RedHat.pm |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index 77f0f3a..1a7afbd 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -87,6 +87,7 @@ sub new
     bless($self, $class);
 
     $self->_init_selinux();
+    $self->_init_modules();
     $self->_init_augeas();
 
     return $self;
@@ -168,10 +169,9 @@ sub _init_selinux
     $g->touch('/.autorelabel');
 }
 
-sub _init_augeas
+sub _init_modules
 {
     my $self = shift;
-
     my $g = $self->{g};
 
     # Check how new modules should be configured. Possibilities, in descending
@@ -185,10 +185,8 @@ sub _init_augeas
     # discovered method will be chosen
 
     # Files which the augeas Modprobe lens doesn't look for by default
-    my @modprobe_add = ();
     foreach my $file qw(/etc/conf.modules /etc/modules.conf) {
         if($g->exists($file)) {
-            push(@modprobe_add, $file);
             $self->{modules} = $file;
         }
     }
@@ -205,20 +203,18 @@ sub _init_augeas
 
     die(user_message(__"Unable to find any valid modprobe configuration"))
         unless(defined($self->{modules}));
+}
+
+sub _init_augeas
+{
+    my $self = shift;
+    my $g = $self->{g};
 
     # Initialise augeas
     eval {
         $g->aug_close();
         $g->aug_init("/", 1);
 
-        # Add files which exist, but the augeas Modprobe lens doesn't look for
-        # by default
-        if(scalar(@modprobe_add) > 0) {
-            foreach (@modprobe_add) {
-                $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", $_);
-            }
-        }
-
         # Check if /boot/grub/menu.lst is included by the Grub lens
         my $found = 0;
         foreach my $incl ($g->aug_match("/augeas/load/Grub/incl")) {
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]