[pve-devel] [PATCH 1/9] zfs: move some code

Wolfgang Link w.link at proxmox.com
Fri Jan 23 10:32:37 CET 2015


move the most part of alloc_image to ZFSDirPlugin

Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
 PVE/Storage/ZFSDirPlugin.pm |   14 ++++++++++++++
 PVE/Storage/ZFSPlugin.pm    |   10 ++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/PVE/Storage/ZFSDirPlugin.pm b/PVE/Storage/ZFSDirPlugin.pm
index 929fb20..9960d3a 100644
--- a/PVE/Storage/ZFSDirPlugin.pm
+++ b/PVE/Storage/ZFSDirPlugin.pm
@@ -149,6 +149,20 @@ sub zfs_request {
     return $msg;
 }
 
+sub alloc_image {
+    my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+
+    die "unsupported format '$fmt'" if $fmt ne 'raw';
+
+    die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
+    if $name && $name !~ m/^vm-$vmid-/;
+
+    $name = $class->zfs_find_free_diskname($storeid, $scfg, $vmid) if !$name;
+    
+    $class->zfs_create_zvol($scfg, $name, $size);
+
+}
+
 sub zfs_get_pool_stats {
     my ($class, $scfg) = @_;
 
diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 15cd66e..d47e07e 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -285,15 +285,9 @@ sub clone_image {
 
 sub alloc_image {
     my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+    
+    $class->SUPER::alloc_image($class, $storeid, $scfg, $vmid, $fmt, $name, $size);
 
-    die "unsupported format '$fmt'" if $fmt ne 'raw';
-
-    die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
-    if $name && $name !~ m/^vm-$vmid-/;
-
-    $name = $class->zfs_find_free_diskname($storeid, $scfg, $vmid) if !$name;
-
-    $class->zfs_create_zvol($scfg, $name, $size);
     my $guid = $class->zfs_create_lu($scfg, $name);
     $class->zfs_add_lun_mapping_entry($scfg, $name, $guid);
 
-- 
1.7.10.4





More information about the pve-devel mailing list