[pve-devel] [PATCH qemu-server 3/7] Remove redundant locks

Dominic Jäger d.jaeger at proxmox.com
Fri Oct 25 11:24:03 CEST 2019


The whole $importfn is executed in a lock_config_full. Consequently,
1. lock_config is redundant
2. it is not possible that a lock has been written in the VM's config file
   (check_lock) in the meanwhile
3. it is not possible that the VM has been started (check_running) in the
    meanwhile

Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
 PVE/CLI/qm.pm | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index 6405b42..c93f78d 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -645,7 +645,6 @@ __PACKAGE__->register_method ({
 
 		# reload after disks entries have been created
 		$conf = PVE::QemuConfig->load_config($vmid);
-		PVE::QemuConfig->check_lock($conf);
 		my $firstdisk = PVE::QemuServer::resolve_first_disk($conf);
 		$conf->{bootdisk} = $firstdisk if $firstdisk;
 		PVE::QemuConfig->write_config($vmid, $conf);
@@ -653,15 +652,7 @@ __PACKAGE__->register_method ({
 
 	    my $err = $@;
 	    if ($err) {
-		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";
-			}
-		    });
-		};
+		eval { PVE::QemuServer::destroy_vm($storecfg, $vmid, undef, 1); };
 		die "import failed - $err";
 	    }
 	};
-- 
2.20.1




More information about the pve-devel mailing list