[pve-devel] [PATCH v2 firewall] LXC refactoring

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Mar 3 10:43:36 CET 2016


call cfs_config_path and parse_lxc_network in
PVE::LXC::Config instead of PVE::LXC
---
Rebased on current master

 src/PVE/Firewall.pm          | 6 +++---
 src/PVE/FirewallSimulator.pm | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index dad259e..a7faeaf 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -2714,7 +2714,7 @@ sub read_local_vm_config {
 	    }
         } elsif ($d->{type} eq 'lxc') {
             if ($have_lxc) {
-                my $cfspath = PVE::LXC::cfs_config_path($vmid);
+                my $cfspath = PVE::LXC::Config->cfs_config_path($vmid);
                 if (my $conf = PVE::Cluster::cfs_read_file($cfspath)) {
                     $lxc->{$vmid} = $conf;
                 }
@@ -3255,7 +3255,7 @@ sub compile_iptables_filter {
             if ($vmfw_conf->{options}->{enable}) {
 		foreach my $netid (keys %$conf) {
                     next if $netid !~ m/^net(\d+)$/;
-                    my $net = PVE::LXC::parse_lxc_network($conf->{$netid});
+                    my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid});
                     next if !$net->{firewall};
                     my $iface = "veth${vmid}i$1";
 		    my $macaddr = $net->{hwaddr};
@@ -3365,7 +3365,7 @@ sub compile_ipsets {
 	    my $device_ips = {};
 	    foreach my $netid (keys %$conf) {
 		next if $netid !~ m/^net(\d+)$/;
-		my $net = PVE::LXC::parse_lxc_network($conf->{$netid});
+		my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid});
 		next if !$net->{firewall};
 
 		if ($vmfw_conf->{options}->{ipfilter} && !$ipsets->{"ipfilter-$netid"}) {
diff --git a/src/PVE/FirewallSimulator.pm b/src/PVE/FirewallSimulator.pm
index 73d3bd3..2e9bc38 100644
--- a/src/PVE/FirewallSimulator.pm
+++ b/src/PVE/FirewallSimulator.pm
@@ -443,7 +443,7 @@ sub extract_ct_info {
     my $info = { type => 'ct', vmid => $vmid };
 
     my $conf = $vmdata->{lxc}->{$vmid} || die "no such CT '$vmid'";
-    my $net = PVE::LXC::parse_lxc_network($conf->{"net$netnum"});
+    my $net = PVE::LXC::Config->parse_lxc_network($conf->{"net$netnum"});
     $info->{macaddr} = $net->{hwaddr} || die "unable to get mac address";
     $info->{bridge} = $net->{bridge} || die "unable to get bridge";
     $info->{fwbr} = "fwbr${vmid}i$netnum";
-- 
2.1.4





More information about the pve-devel mailing list