]>
Commit | Line | Data |
---|---|---|
1e3baf05 DM |
1 | #!/usr/bin/perl -w |
2 | ||
3 | use strict; | |
4 | use PVE::QemuServer; | |
5 | use PVE::Tools qw(run_command); | |
9f03d50d | 6 | use PVE::Network; |
1e3baf05 DM |
7 | |
8 | my $iface = shift; | |
9 | ||
10 | die "no interface specified\n" if !$iface; | |
11 | ||
12 | die "got strange interface name '$iface'\n" | |
13 | if $iface !~ m/^tap(\d+)i(\d+)$/; | |
14 | ||
15 | my $vmid = $1; | |
16 | my $netid = "net$2"; | |
17 | ||
d691e6d3 DM |
18 | my $migratedfrom = $ENV{PVE_MIGRATED_FROM}; |
19 | ||
20 | my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom); | |
1e3baf05 DM |
21 | |
22 | die "unable to get network config '$netid'\n" | |
23 | if !$conf->{$netid}; | |
24 | ||
25 | my $net = PVE::QemuServer::parse_net($conf->{$netid}); | |
26 | die "unable to parse network config '$netid'\n" if !$net; | |
27 | ||
56ccc25d | 28 | PVE::Network::tap_create($iface, $net->{bridge}); |
1e3baf05 | 29 | |
041dd2d8 | 30 | PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate}; |
3c720aea | 31 | |
9d791466 | 32 | PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}); |
1e3baf05 DM |
33 | |
34 | exit 0; |