]> git.proxmox.com Git - qemu-server.git/blame - pve-bridge-hotplug
add pve-bridge-hotplug script
[qemu-server.git] / pve-bridge-hotplug
CommitLineData
208ba94e
AD
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use PVE::QemuServer;
6use PVE::Tools qw(run_command);
7use PVE::Network;
8
9my $iface = shift;
10
11die "no interface specified\n" if !$iface;
12
13die "got strange interface name '$iface'\n"
14 if $iface !~ m/^tap(\d+)i(\d+)$/;
15
16my $vmid = $1;
17my $netid = "net$2";
18
19my $conf = PVE::QemuServer::load_config($vmid);
20
21my $netconf = $conf->{$netid};
22
23$netconf = $conf->{pending}->{$netid} if defined($conf->{pending}->{$netid});
24
25die "unable to get network config '$netid'\n"
26 if !defined($netconf);
27
28my $net = PVE::QemuServer::parse_net($netconf);
29die "unable to parse network config '$netid'\n" if !$net;
30
31PVE::Network::tap_create($iface, $net->{bridge});
32
33# if ovs is under this bridge all traffic control settings will be flushed.
34# so we need to call tap_rate_limit after tap_plug
35PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall});
36
37PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
38
39exit 0;