[pve-devel] [PATCH] bug-fix: ZFSPoolPlugin

Wolfgang Link w.link at proxmox.com
Thu Feb 12 11:26:30 CET 2015


improve Error handling.
inform user only if there is really no device.
if both checks are fail.

Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
 PVE/Storage/ZFSPoolPlugin.pm |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 7dc7d3e..231d109 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -180,14 +180,26 @@ sub alloc_image {
     $name = $class->zfs_find_free_diskname($storeid, $scfg, $vmid) if !$name;
     
     $class->zfs_create_zvol($scfg, $name, $size);
-    run_command ("udevadm trigger --subsystem-match block");
-    run_command ("udevadm settle --timeout 5");
-    
+
+    eval {
+	run_command ("udevadm trigger --subsystem-match block");
+	run_command ("udevadm settle --timeout 5");
+    };
+
+    my $warn = @$;
+
+    my $create_ok;
+
     for (1..10) {
-       last if -e "/dev/zvol/$scfg->{pool}/$name" ;
+	if (-e "/dev/zvol/$scfg->{pool}/$name") {
+	    $create_ok = 1;
+	    last;
+	}
        Time::HiRes::usleep(100);
     }
 
+    die "can't alloc image\n" unless  $create_ok;
+
     return $name;
 }
 
-- 
1.7.10.4





More information about the pve-devel mailing list