On 02/12/2015 11:26 AM, Wolfgang Link wrote:
improve Error handling.
inform user only if there is really no device.
if both checks are fail.

Signed-off-by: Wolfgang Link <w.l...@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 = @$;
what is that? I guess you want:

 warn $@ if $@;

instead?

+
+    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;
+

We just want to wait until udev create the device /dev/zvol, but we do not want to
raise additional error (zfs alloctated the image successfully).
So above change makes no sense to me.

      return $name;
  }


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to