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

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



On Thu, Feb 18, 2010 at 09:49:44AM +0000, Matthew Booth wrote:
> 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

ACK, looks sensible.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora


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