Use a common interface for find_free_diskname

We can use 'list_images' to get the desired volume IDs in
'find_free_diskname' for most plugins. For the two LVM plugins, 'list_images'
potentially skips untagged volumes, so we keep the custom version. For the
RBD plugin, 'list_images' is much more costly than the custom version, so we
keep the custom version.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner
2019-12-11 10:25:49 +01:00
committed by Thomas Lamprecht
parent a573f66a2e
commit a44c0147bc
7 changed files with 30 additions and 50 deletions

View File

@ -95,9 +95,7 @@ sub alloc_image {
die "no such volume group '$vg'\n" if !defined ($vgs->{$vg});
my $lvs = PVE::Storage::LVMPlugin::lvm_list_volumes($vg);
$name = PVE::Storage::LVMPlugin::lvm_find_free_diskname($lvs, $vg, $storeid, $vmid, $scfg)
$name = $class->find_free_diskname($storeid, $scfg, $vmid)
if !$name;
my $cmd = ['/sbin/lvcreate', '-aly', '-V', "${size}k", '--name', $name,
@ -268,9 +266,7 @@ sub clone_image {
$lv = "$vg/$volname";
}
my $lvs = PVE::Storage::LVMPlugin::lvm_list_volumes($vg);
my $name = PVE::Storage::LVMPlugin::lvm_find_free_diskname($lvs, $vg, $storeid, $vmid, $scfg);
my $name = $class->find_free_diskname($storeid, $scfg, $vmid);
my $cmd = ['/sbin/lvcreate', '-n', $name, '-prw', '-kn', '-s', $lv];
run_command($cmd, errmsg => "clone image '$lv' error");