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

[Libguestfs] [PATCH 1/2] SSH: Check for complete transfer of disk images



---
 lib/Sys/VirtV2V/Transfer/SSH.pm |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/Sys/VirtV2V/Transfer/SSH.pm b/lib/Sys/VirtV2V/Transfer/SSH.pm
index 3b08716..ac5a384 100644
--- a/lib/Sys/VirtV2V/Transfer/SSH.pm
+++ b/lib/Sys/VirtV2V/Transfer/SSH.pm
@@ -82,6 +82,7 @@ sub transfer
     my $vol = $target->create_volume($name, $size);
     $vol->open();
 
+    my $written = 0;
     for (;;) {
         my $buffer;
         # Transfer in 8k chunks
@@ -93,10 +94,16 @@ sub transfer
         last if ($in == 0);
 
         $vol->write($buffer);
+        $written += length($buffer);
     }
 
     $vol->close();
 
+    die(user_message(__x("Didn't receive full volume. Received {received} ".
+                         "of {total} bytes.",
+                         received => $written,
+                         total => $size))) unless ($written == $size);
+
     waitpid($pid, 0) == $pid or die("error reaping child: $!");
     # If the child returned an error, check for anything on its stderr
     if ($? != 0) {
-- 
1.6.6.1


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