]> git.proxmox.com Git - qemu-server.git/blob - pve-bridge
pve-bridge : move tap_plug code in PVE::Network::tap_plug
[qemu-server.git] / pve-bridge
1 #!/usr/bin/perl -w
2
3 use strict;
4 use PVE::QemuServer;
5 use PVE::Tools qw(run_command);
6 use PVE::Network;
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
18 my $migratedfrom = $ENV{PVE_MIGRATED_FROM};
19
20 my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom);
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
28 PVE::Network::tap_create($iface, $net->{bridge});
29
30 PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
31
32 PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag});
33
34 exit 0;