[pve-devel] [PATCH 3/3] fwbr bridge cleanup on container umount

Alexandre Derumier aderumier at odiso.com
Fri May 23 15:11:38 CEST 2014


call proxmox.umount script, on container umount.
Works if the container is shutdown from vzctl or inside guest with shutdown command

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 debian/patches/bridge-cleanup.patch |   27 +++++++++++++++++++++++++++
 debian/patches/series               |    1 +
 debian/proxmox.umount               |   26 ++++++++++++++++++++++++++
 debian/rules                        |    3 +++
 4 files changed, 57 insertions(+)
 create mode 100644 debian/patches/bridge-cleanup.patch
 create mode 100755 debian/proxmox.umount

diff --git a/debian/patches/bridge-cleanup.patch b/debian/patches/bridge-cleanup.patch
new file mode 100644
index 0000000..8ea71a9
--- /dev/null
+++ b/debian/patches/bridge-cleanup.patch
@@ -0,0 +1,27 @@
+From 07e05c92bb26ceb8b88dfbc4e5b9f3a8406d7268 Mon Sep 17 00:00:00 2001
+From: Alexandre Derumier <aderumier at odiso.com>
+Date: Fri, 23 May 2014 14:53:04 +0200
+Subject: [PATCH] execute proxmox.umount script on filesystem umount
+
+
+Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
+---
+ src/lib/fs.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/lib/fs.c b/src/lib/fs.c
+index c02cbea..342cf7c 100644
+--- a/src/lib/fs.c
++++ b/src/lib/fs.c
+@@ -216,6 +216,8 @@ int vps_umount(vps_handler *h, envid_t veid, const fs_param *fs,
+ 			}
+ 			snprintf(buf, sizeof(buf), "%svps.%s", VPS_CONF_DIR,
+ 				UMOUNT_PREFIX);
++			snprintf(buf, sizeof(buf), "%s/proxmox.%s", SCRIPTDIR,
++				UMOUNT_PREFIX);
+ 		}
+ 	}
+ 	if (!(ret = fsumount(veid, fs)))
+-- 
+1.7.10.4
+
diff --git a/debian/patches/series b/debian/patches/series
index 9dab92c..9a30459 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,3 +10,4 @@ always-create-dev-console.patch
 #keep-bridge-MTU.patch
 fix-vzifup-post-error.patch
 pass-bridge-value-as-argument-to-VZNETCFG.patch
+bridge-cleanup.patch
diff --git a/debian/proxmox.umount b/debian/proxmox.umount
new file mode 100755
index 0000000..d6457df
--- /dev/null
+++ b/debian/proxmox.umount
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use PVE::OpenVZ;
+use PVE::Tools qw(run_command);
+use PVE::Network;
+use PVE::ProcFSTools;
+use Data::Dumper;
+
+my $vmid = $ENV{VEID};
+die "missing vmid parameter" if !$vmid;
+
+my $conf = PVE::OpenVZ::load_config($vmid);
+
+my $ifaces = {};
+if (defined ($conf->{netif}) && $conf->{netif}->{value}) {
+	$ifaces = PVE::OpenVZ::parse_netif($conf->{netif}->{value}, $vmid);
+}
+
+foreach my $ifname (sort keys %$ifaces) {
+    PVE::Network::tap_unplug($ifaces->{$ifname}->{host_ifname});
+}
+
+exit 0;
+
+
diff --git a/debian/rules b/debian/rules
index c9805fd..e29db56 100644
--- a/debian/rules
+++ b/debian/rules
@@ -98,6 +98,9 @@ install: build
 	# install perl vznetaddbr version
 	install -m 644 $(CURDIR)/debian/vznetaddbr $(CURDIR)/debian/vzctl/usr/sbin/vznetaddbr
 
+	# install proxmox bridge cleanup script
+	install -m 644 $(CURDIR)/debian/proxmox.umount $(CURDIR)/debian/vzctl/usr/lib/vzctl/scripts/proxmox.umount
+
 
 
 # Build architecture-independent files here.
-- 
1.7.10.4




More information about the pve-devel mailing list