[pve-devel] [PATCH 2/2] add pve-bridgedown script

Alexandre Derumier aderumier at odiso.com
Mon May 5 09:40:27 CEST 2014


This allow to delete fwbr bridge, link interfaces, cleanup ovs
when vm is shutdown

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 Makefile          |    1 +
 PVE/QemuServer.pm |    2 +-
 pve-bridgedown    |   16 ++++++++++++++++
 3 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100755 pve-bridgedown

diff --git a/Makefile b/Makefile
index 536b9cb..57ab8ee 100644
--- a/Makefile
+++ b/Makefile
@@ -81,6 +81,7 @@ install: ${PKGSOURCES}
 	install -D -m 0755 qmupdate ${DESTDIR}${VARLIBDIR}/qmupdate
 	install -D -m 0755 qemu.init.d ${DESTDIR}/etc/init.d/${PACKAGE}
 	install -m 0755 pve-bridge ${DESTDIR}${VARLIBDIR}/pve-bridge
+	install -m 0755 pve-bridgedown ${DESTDIR}${VARLIBDIR}/pve-bridgedown
 	install -s -m 0755 vmtar ${DESTDIR}${LIBDIR}
 	install -s -m 0755 sparsecp ${DESTDIR}${LIBDIR}
 	install -m 0755 qmextract ${DESTDIR}${LIBDIR}
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 5489751..4f93f34 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1202,7 +1202,7 @@ sub print_netdev_full {
     my $vmname = $conf->{name} || "vm$vmid";
 
     if ($net->{bridge}) {
-        return "type=tap,id=$netid,ifname=${ifname},script=/var/lib/qemu-server/pve-bridge$vhostparam";
+        return "type=tap,id=$netid,ifname=${ifname},script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown$vhostparam";
     } else {
         return "type=user,id=$netid,hostname=$vmname";
     }
diff --git a/pve-bridgedown b/pve-bridgedown
new file mode 100755
index 0000000..d18d88f
--- /dev/null
+++ b/pve-bridgedown
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use PVE::Network;
+
+my $iface = shift;
+
+die "no interface specified\n" if !$iface;
+
+die "got strange interface name '$iface'\n" 
+    if $iface !~ m/^tap(\d+)i(\d+)$/;
+
+PVE::Network::tap_unplug($iface);
+
+exit 0;
-- 
1.7.10.4




More information about the pve-devel mailing list