From 50669ed5c0795abb672ec8ba7c243163b5d0f5f4 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 13 Nov 2015 16:16:01 +0100 Subject: [PATCH] pve-bridge-hotplug code deduplication --- pve-bridge | 8 +++++++- pve-bridge-hotplug | 40 ++-------------------------------------- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/pve-bridge b/pve-bridge index b4550f1c..c23c6439 100755 --- a/pve-bridge +++ b/pve-bridge @@ -8,6 +8,12 @@ use PVE::Network; my $iface = shift; +my $hotplug = 0; +if ($iface eq '--hotplug') { + $hotplug = 1; + $iface = shift; +} + die "no interface specified\n" if !$iface; die "got strange interface name '$iface'\n" @@ -16,7 +22,7 @@ die "got strange interface name '$iface'\n" my $vmid = $1; my $netid = "net$2"; -my $migratedfrom = $ENV{PVE_MIGRATED_FROM}; +my $migratedfrom = $hotplug ? undef : $ENV{PVE_MIGRATED_FROM}; my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom); diff --git a/pve-bridge-hotplug b/pve-bridge-hotplug index 2131db58..f36ed408 100755 --- a/pve-bridge-hotplug +++ b/pve-bridge-hotplug @@ -1,39 +1,3 @@ -#!/usr/bin/perl +#!/bin/sh -use strict; -use warnings; -use PVE::QemuServer; -use PVE::Tools qw(run_command); -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+)$/; - -my $vmid = $1; -my $netid = "net$2"; - -my $conf = PVE::QemuServer::load_config($vmid); - -my $netconf = $conf->{$netid}; - -$netconf = $conf->{pending}->{$netid} if defined($conf->{pending}->{$netid}); - -die "unable to get network config '$netid'\n" - if !defined($netconf); - -my $net = PVE::QemuServer::parse_net($netconf); -die "unable to parse network config '$netid'\n" if !$net; - -PVE::Network::tap_create($iface, $net->{bridge}); - -# if ovs is under this bridge all traffic control settings will be flushed. -# so we need to call tap_rate_limit after tap_plug -PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall}); - -PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate}; - -exit 0; +exec /var/lib/qemu-server/pve-bridge --hotplug "$@"