[pve-devel] [PATCH firewall] LXC refactoring

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Mar 2 13:54:38 CET 2016


call cfs_config_path and parse_lxc_network in
PVE::LXC::Config instead of PVE::LXC
---
Note: this depends on the patch series against pve-container
and the single patch against pve-common.

 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 1479d3b..722db29 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};
@@ -3343,7 +3343,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};
 
 		my $macaddr = $net->{hwaddr};
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