]> git.proxmox.com Git - pve-firewall.git/commitdiff
clone_vmfw_conf: lock new config
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 29 Apr 2020 08:52:53 +0000 (10:52 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 2 May 2020 17:05:49 +0000 (19:05 +0200)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/Firewall.pm

index 84f71d6fcfebc161c97043a3bf0c69e25d1906d8..c34216758acfffdcd020c707521ac6bd0b26a468 100644 (file)
@@ -3282,13 +3282,15 @@ sub clone_vmfw_conf {
     my $sourcevm_conffile = "$pvefw_conf_dir/$vmid.fw";
     my $clonevm_conffile = "$pvefw_conf_dir/$newid.fw";
 
     my $sourcevm_conffile = "$pvefw_conf_dir/$vmid.fw";
     my $clonevm_conffile = "$pvefw_conf_dir/$newid.fw";
 
-    if (-f $clonevm_conffile) {
-       unlink $clonevm_conffile;
-    }
-    if (-f $sourcevm_conffile) {
-       my $data = PVE::Tools::file_get_contents($sourcevm_conffile);
-       PVE::Tools::file_set_contents($clonevm_conffile, $data);
-    }
+    lock_vmfw_conf($newid, 10, sub {
+       if (-f $clonevm_conffile) {
+           unlink $clonevm_conffile;
+       }
+       if (-f $sourcevm_conffile) {
+           my $data = PVE::Tools::file_get_contents($sourcevm_conffile);
+           PVE::Tools::file_set_contents($clonevm_conffile, $data);
+       }
+    });
 }
 
 sub read_vm_firewall_configs {
 }
 
 sub read_vm_firewall_configs {