From ca04180f3b8f9d93cb45002fb9e530ad0c5c4b25 Mon Sep 17 00:00:00 2001 From: Wolfgang Link Date: Fri, 23 Jan 2015 10:32:40 +0100 Subject: [PATCH] zfs: move methode list_image Signed-off-by: Wolfgang Link --- PVE/Storage/ZFSDirPlugin.pm | 39 +++++++++++++++++++++++++++++++++++++ PVE/Storage/ZFSPlugin.pm | 39 ------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/PVE/Storage/ZFSDirPlugin.pm b/PVE/Storage/ZFSDirPlugin.pm index 84ffe39..a0dab99 100644 --- a/PVE/Storage/ZFSDirPlugin.pm +++ b/PVE/Storage/ZFSDirPlugin.pm @@ -184,6 +184,45 @@ sub free_image { return undef; } +sub list_images { + my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_; + + $cache->{zfs} = $class->zfs_list_zvol($scfg) if !$cache->{zfs}; + my $zfspool = $scfg->{pool}; + my $res = []; + + if (my $dat = $cache->{zfs}->{$zfspool}) { + + foreach my $image (keys %$dat) { + + my $volname = $dat->{$image}->{name}; + my $parent = $dat->{$image}->{parent}; + + my $volid = undef; + if ($parent && $parent =~ m/^(\S+)@(\S+)$/) { + my ($basename) = ($1); + $volid = "$storeid:$basename/$volname"; + } else { + $volid = "$storeid:$volname"; + } + + my $owner = $dat->{$volname}->{vmid}; + if ($vollist) { + my $found = grep { $_ eq $volid } @$vollist; + next if !$found; + } else { + next if defined ($vmid) && ($owner ne $vmid); + } + + my $info = $dat->{$volname}; + $info->{volid} = $volid; + push @$res, $info; + } + } + + return $res; +} + sub zfs_get_pool_stats { my ($class, $scfg) = @_; diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm index a5e3fb2..9bc1c83 100644 --- a/PVE/Storage/ZFSPlugin.pm +++ b/PVE/Storage/ZFSPlugin.pm @@ -301,45 +301,6 @@ sub free_image { return undef; } -sub list_images { - my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_; - - $cache->{zfs} = $class->zfs_list_zvol($scfg) if !$cache->{zfs}; - my $zfspool = $scfg->{pool}; - my $res = []; - - if (my $dat = $cache->{zfs}->{$zfspool}) { - - foreach my $image (keys %$dat) { - - my $volname = $dat->{$image}->{name}; - my $parent = $dat->{$image}->{parent}; - - my $volid = undef; - if ($parent && $parent =~ m/^(\S+)@(\S+)$/) { - my ($basename) = ($1); - $volid = "$storeid:$basename/$volname"; - } else { - $volid = "$storeid:$volname"; - } - - my $owner = $dat->{$volname}->{vmid}; - if ($vollist) { - my $found = grep { $_ eq $volid } @$vollist; - next if !$found; - } else { - next if defined ($vmid) && ($owner ne $vmid); - } - - my $info = $dat->{$volname}; - $info->{volid} = $volid; - push @$res, $info; - } - } - - return $res; -} - sub activate_storage { my ($class, $storeid, $scfg, $cache) = @_; return 1;