[pve-devel] [PATCH qemu-server] merge delete_drive into try_deallocate_drive

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Aug 13 11:15:56 CEST 2015


It used to be private and is only used once.
---
 PVE/QemuServer.pm | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 01593cc..5f14a90 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4123,18 +4123,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) = @_;
 
@@ -4143,7 +4131,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;
 	}
     }
-- 
2.1.4





More information about the pve-devel mailing list