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

[Libguestfs] [PATCH 2/2] GuestOS: Handle the case where a module has been removed since inspection



Removing VMwareTools will delete some modprobe entries entirely, which caused an
error when calling update_kernel_module. This change handles that gracefully.
---
 lib/Sys/VirtV2V/GuestOS/RedHat.pm |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index 380dacb..97bb32d 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -293,6 +293,9 @@ sub update_kernel_module
     my $g = $self->{g};
     $augeas = $self->_check_augeas_device($augeas, $device);
 
+    # If the module has mysteriously disappeared, just add a new one
+    return $self->enable_kernel_module($device, $module) if (!defined($augeas));
+
     eval {
         $g->aug_set($augeas."/modulename", $module);
         $g->aug_save();
@@ -323,6 +326,10 @@ sub disable_kernel_module
     my $g = $self->{g};
 
     $augeas = $self->_check_augeas_device($augeas, $device);
+
+    # Nothing to do if the module has gone away
+    return if (!defined($augeas));
+
     eval {
         $g->aug_rm($augeas);
     };
@@ -388,8 +395,7 @@ sub _check_augeas_device
     # Propagate augeas errors
     die($@) if($@);
 
-    return $augeas if(defined($augeas));
-    die("Unable to find augeas path similar to $path for $device");
+    return $augeas;
 }
 
 =item get_default_kernel()
-- 
1.6.6


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