The variable was used in one place only. Nesting the code into the
lock_config_full makes clear what code is locked.

Signed-off-by: Dominic Jäger <d.jae...@proxmox.com>
---
 PVE/CLI/qm.pm | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index c93f78d..a378d3d 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -625,10 +625,9 @@ __PACKAGE__->register_method ({
        $param->{memory} = $parsed->{qm}->{memory} if 
defined($parsed->{qm}->{memory});
        $param->{cores} = $parsed->{qm}->{cores} if 
defined($parsed->{qm}->{cores});
 
-       my $importfn = sub {
-
+       # why is wait_for_lock exactly 1?
+       PVE::QemuConfig->lock_config_full($vmid, 1, sub {
            PVE::Cluster::check_vmid_unused($vmid);
-
            my $conf = $param;
 
            eval {
@@ -649,16 +648,12 @@ __PACKAGE__->register_method ({
                $conf->{bootdisk} = $firstdisk if $firstdisk;
                PVE::QemuConfig->write_config($vmid, $conf);
            };
-
            my $err = $@;
            if ($err) {
                eval { PVE::QemuServer::destroy_vm($storecfg, $vmid, undef, 1); 
};
                die "import failed - $err";
            }
-       };
-
-       my $wait_for_lock = 1;
-       PVE::QemuConfig->lock_config_full($vmid, $wait_for_lock, $importfn);
+       });
 
        return undef;
 
-- 
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