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