since 'pvesm export' and 'pvesm import' are connected via a pipe and
SSH, a fatal error in the former can lead to no valid header being
written to the pipe. handle this more gracefully by printing an easier
to understand error message, instead of uninitialized warnings with no
context.

Signed-off-by: Fabian Grünbichler <[email protected]>
---

Notes:
    this can be triggered by migrating a VM with a non-existing LV.
    
    this changes the output from:
    
    Use of uninitialized value $size in bitwise and (&) at 
/usr/share/perl5/PVE/Storage/Plugin.pm line 1118, <DATA> line 755.
    Use of uninitialized value $size in division (/) at 
/usr/share/perl5/PVE/Storage/LVMPlugin.pm line 626, <DATA> line 755.
      --virtualsize may not be zero.
    lvcreate 'pve/vm-102-disk-0' error:   Run `lvcreate --help' for more 
information.
    
    to
    
    import: no size found in export header, aborting.

 PVE/Storage/Plugin.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 283eafc..963c391 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -1115,6 +1115,7 @@ sub read_common_header($) {
     my ($fh) = @_;
     sysread($fh, my $size, 8);
     $size = unpack('Q<', $size);
+    die "import: no size found in export header, aborting.\n" if 
!defined($size);
     die "got a bad size (not a multiple of 1K)\n" if ($size&1023);
     # Size is in bytes!
     return $size;
-- 
2.20.1


_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to