[pve-devel] [PATCH firewall 4/7] clone_vmfw_conf: lock new config
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Apr 29 10:52:53 CEST 2020
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
Notes:
best viewed with -w
src/PVE/Firewall.pm | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index eda39eb..7b26ac5 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -3282,13 +3282,15 @@ sub clone_vmfw_conf {
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 {
--
2.20.1
More information about the pve-devel
mailing list