Fix #1858: lvm_find_free_diskname check for base

lvm_find_free_diskname only checked for existing volumes starting with 'vm-',
and not with 'base-'.

Unify implementation with other Plugins.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
Stoiko Ivanov
2018-08-06 16:01:15 +02:00
committed by Dietmar Maurer
parent f15ac9b5a8
commit ca552c7639

View File

@ -293,18 +293,21 @@ sub lvm_find_free_diskname {
my $name; my $name;
for (my $i = 1; $i < 100; $i++) { my $disk_ids = {};
my $tn = "vm-$vmid-disk-$i"; my @vols = keys(%{$lvs->{$vg}});
if (!defined ($lvs->{$vg}->{$tn})) {
$name = $tn; foreach my $vol (@vols) {
last; if ($vol =~ m/(vm|base)-\Q$vmid\E-disk-(\d+)/){
$disk_ids->{$2} = 1;
} }
} }
die "unable to allocate an image name for ID $vmid in storage '$storeid'\n" for (my $i = 1; $i < 100; $i++) {
if !$name; return "vm-$vmid-disk-$i" if !$disk_ids->{$i};
}
die "unable to allocate an image name for ID $vmid in storage '$storeid'\n";
return $name;
} }
sub alloc_image { sub alloc_image {