mirror of
git://git.proxmox.com/git/pve-storage.git
synced 2025-01-26 10:03:52 +03:00
zfs: list images: code cleanup
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
4470f0cbe9
commit
39eb268662
@ -254,36 +254,30 @@ sub free_image {
|
|||||||
sub list_images {
|
sub list_images {
|
||||||
my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
|
my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
|
||||||
|
|
||||||
my $zfs_list = $class->zfs_list_zvol($scfg);
|
my $zfs_list = $class->zfs_list_zvol($scfg) // {};
|
||||||
|
|
||||||
my $res = [];
|
my $res = [];
|
||||||
|
|
||||||
if (my $dat = $zfs_list) {
|
for my $info (values $zfs_list->%*) {
|
||||||
|
my $volname = $info->{name};
|
||||||
|
my $parent = $info->{parent};
|
||||||
|
my $owner = $info->{vmid};
|
||||||
|
|
||||||
foreach my $image (keys %$dat) {
|
if ($parent && $parent =~ m/^(\S+)\@__base__$/) {
|
||||||
|
my ($basename) = ($1);
|
||||||
my $info = $dat->{$image};
|
$info->{volid} = "$storeid:$basename/$volname";
|
||||||
|
} else {
|
||||||
my $volname = $info->{name};
|
$info->{volid} = "$storeid:$volname";
|
||||||
my $parent = $info->{parent};
|
|
||||||
my $owner = $info->{vmid};
|
|
||||||
|
|
||||||
if ($parent && $parent =~ m/^(\S+)\@__base__$/) {
|
|
||||||
my ($basename) = ($1);
|
|
||||||
$info->{volid} = "$storeid:$basename/$volname";
|
|
||||||
} else {
|
|
||||||
$info->{volid} = "$storeid:$volname";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($vollist) {
|
|
||||||
my $found = grep { $_ eq $info->{volid} } @$vollist;
|
|
||||||
next if !$found;
|
|
||||||
} else {
|
|
||||||
next if defined ($vmid) && ($owner ne $vmid);
|
|
||||||
}
|
|
||||||
|
|
||||||
push @$res, $info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($vollist) {
|
||||||
|
my $found = grep { $_ eq $info->{volid} } @$vollist;
|
||||||
|
next if !$found;
|
||||||
|
} else {
|
||||||
|
next if defined ($vmid) && ($owner ne $vmid);
|
||||||
|
}
|
||||||
|
|
||||||
|
push @$res, $info;
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user