This function has been used in one place only. Removing it avoids confusion
between vm_destroy and vm_destroy.

Signed-off-by: Dominic Jäger <d.jae...@proxmox.com>
---
I copied all the checks from vm_destroy even if they were useless.
Removing those useless functions is a follow up patch.$

 PVE/CLI/qm.pm     | 11 +++++++++--
 PVE/QemuServer.pm | 15 ---------------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index ea74ad5..6405b42 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -653,8 +653,15 @@ __PACKAGE__->register_method ({
 
            my $err = $@;
            if ($err) {
-               my $skiplock = 1;
-               eval { PVE::QemuServer::vm_destroy($storecfg, $vmid, 
$skiplock); };
+               eval {
+                   PVE::QemuConfig->lock_config($vmid, sub {
+                       if (!PVE::QemuServer::check_running($vmid)) {
+                           PVE::QemuServer::destroy_vm($storecfg, $vmid, 
undef, 1);
+                       } else {
+                           die "VM $vmid is running - destroy failed\n";
+                       }
+                   });
+               };
                die "import failed - $err";
            }
        };
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 328a0d1..0a29e21 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5943,21 +5943,6 @@ sub vm_sendkey {
     });
 }
 
-sub vm_destroy {
-    my ($storecfg, $vmid, $skiplock) = @_;
-
-    PVE::QemuConfig->lock_config($vmid, sub {
-
-       my $conf = PVE::QemuConfig->load_config($vmid);
-
-       if (!check_running($vmid)) {
-           destroy_vm($storecfg, $vmid, undef, $skiplock);
-       } else {
-           die "VM $vmid is running - destroy failed\n";
-       }
-    });
-}
-
 # vzdump restore implementaion
 
 sub tar_archive_read_firstfile {
-- 
2.20.1

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to