[pve-devel] [PATCH] clone vm firewall config

Alen Grizonic a.grizonic at proxmox.com
Fri Aug 21 17:12:34 CEST 2015


clone vm firewall config file when cloning vm

Signed-off-by: Alen Grizonic <a.grizonic at proxmox.com>
---
 src/PVE/Firewall.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index 5962a4f..ffe1abe 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -14,6 +14,7 @@ use PVE::ProcFSTools;
 use PVE::Tools qw($IPV4RE $IPV6RE);
 use File::Basename;
 use File::Path;
+use File::Copy;
 use IO::File;
 use Net::IP;
 use PVE::Tools qw(run_command lock_file dir_glob_foreach);
@@ -2827,6 +2828,20 @@ sub remove_vmfw_conf {
     unlink $vmfw_conffile;
 }
 
+sub clone_vmfw_conf {
+    my ($vmid, $newid) = @_;
+
+    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) {
+        copy($sourcevm_conffile, $clonevm_conffile) or die "unable to clone firewall config file";
+    }
+}
+
 sub read_vm_firewall_configs {
     my ($cluster_conf, $vmdata, $dir, $verbose) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list