Matthew Booth
2010-Feb-18 09:49 UTC
[Libguestfs] [PATCH 1/2] ESX: Look harder for potential transfer failures
Although I can't reproduce, I seem to have had an incomplete transfer which wasn't picked up by the existing error handling. This change adds some more sanity checks: * Check for error on close() (should have been doing this anyway) * Check that the bytes received == reported content length --- lib/Sys/VirtV2V/Transfer/ESX.pm | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/lib/Sys/VirtV2V/Transfer/ESX.pm b/lib/Sys/VirtV2V/Transfer/ESX.pm index f270938..1da382a 100644 --- a/lib/Sys/VirtV2V/Transfer/ESX.pm +++ b/lib/Sys/VirtV2V/Transfer/ESX.pm @@ -140,6 +140,7 @@ sub get_volume "{error}", error => $@->stringify()))); } + $self->{_v2v_received} = 0; my $r = $self->SUPER::get($url, ':content_cb' => sub { $self->handle_data(@_); }, ':read_size_hint' => 64 * 1024); @@ -150,10 +151,18 @@ sub get_volume die($died) if (defined($died)); # Close the volume file descriptor - close($self->{_v2v_volfh}); + close($self->{_v2v_volfh}) + or die(user_message(__x("Error closing volume handle: {error}", + error => $!))); return $self->{_v2v_vol}; } + die(user_message(__x("Didn't receive full volume. Received {received} of ". + "{total} bytes.", + received => $self->{_v2v_received}, + total => $self->{_v2v_volsize}))) + unless ($self->{_v2v_received} == $self->{_v2v_volsize}); + if ($r->code == 401) { die(user_message(__x("Authentication error connecting to ". "{server}. Used credentials for {username} ". @@ -185,6 +194,8 @@ sub handle_data my $volfh = $self->{_v2v_volfh}; + $self->{_v2v_received} += length($data); + syswrite($volfh, $data) or die(user_message(__x("Error writing to {path}: {error}", path => $self->{_v2v_volpath}, @@ -205,6 +216,7 @@ sub create_volume unless (defined($name)); my $size = $response->content_length(); + $self->{_v2v_volsize} = $size; my $vol_xml = " <volume> -- 1.6.6
Matthew Booth
2010-Feb-18 09:49 UTC
[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
Richard W.M. Jones
2010-Feb-19 09:53 UTC
[Libguestfs] [PATCH 1/2] ESX: Look harder for potential transfer failures
On Thu, Feb 18, 2010 at 09:49:43AM +0000, Matthew Booth wrote:> Although I can't reproduce, I seem to have had an incomplete transfer which > wasn't picked up by the existing error handling. This change adds some more > sanity checks: > > * Check for error on close() (should have been doing this anyway) > * Check that the bytes received == reported content lengthYup, this seems sensible. Next step would be to try error recovery by issuing an HTTP Range request for the rest of the content, but reporting the error is a good start. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/