merge delete_drive into try_deallocate_drive

It used to be private and is only used once.
This commit is contained in:
Wolfgang Bumiller 2015-08-13 11:15:56 +02:00 committed by Dietmar Maurer
parent 3dc38fbb74
commit cee01bcbd7

View File

@ -4022,18 +4022,6 @@ sub vmconfig_hotplug_pending {
}
}
sub delete_drive {
my ($vmid, $storecfg, $conf, $key, $volid) = @_;
# check if the disk is really unused
my $used_paths = PVE::QemuServer::get_used_paths($vmid, $storecfg, $conf, 1, $key);
my $path = PVE::Storage::path($storecfg, $volid);
die "unable to delete '$volid' - volume is still in use (snapshot?)\n"
if $used_paths->{$path};
PVE::Storage::vdisk_free($storecfg, $volid);
}
sub try_deallocate_drive {
my ($storecfg, $vmid, $conf, $key, $drive, $rpcenv, $authuser, $force) = @_;
@ -4042,7 +4030,13 @@ sub try_deallocate_drive {
if (vm_is_volid_owner($storecfg, $vmid, $volid)) {
my $sid = PVE::Storage::parse_volume_id($volid);
$rpcenv->check($authuser, "/storage/$sid", ['Datastore.AllocateSpace']);
delete_drive($vmid, $storecfg, $conf, $key, $drive->{file});
# check if the disk is really unused
my $used_paths = PVE::QemuServer::get_used_paths($vmid, $storecfg, $conf, 1, $key);
my $path = PVE::Storage::path($storecfg, $volid);
die "unable to delete '$volid' - volume is still in use (snapshot?)\n"
if $used_paths->{$path};
PVE::Storage::vdisk_free($storecfg, $volid);
return 1;
}
}