[pve-devel] [PATCH 4/9] zfs: move methode list_image
Wolfgang Link
w.link at proxmox.com
Fri Jan 23 10:32:40 CET 2015
Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
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 e3c1a9d..fb7a1a2 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 f17d2a9..d7d5c6c 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;
--
1.7.10.4
More information about the pve-devel
mailing list