]> git.proxmox.com Git - qemu-server.git/blame - pve-bridge
correctly handle empty description in pending section
[qemu-server.git] / pve-bridge
CommitLineData
990fc5e2 1#!/usr/bin/perl
1e3baf05
DM
2
3use strict;
990fc5e2 4use warnings;
1e3baf05
DM
5use PVE::QemuServer;
6use PVE::Tools qw(run_command);
9f03d50d 7use PVE::Network;
1e3baf05
DM
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
d691e6d3
DM
19my $migratedfrom = $ENV{PVE_MIGRATED_FROM};
20
21my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom);
1e3baf05 22
3eec5767
DM
23my $netconf = $conf->{$netid};
24
25$netconf = $conf->{pending}->{$netid} if !$migratedfrom && defined($conf->{pending}->{$netid});
26
1e3baf05 27die "unable to get network config '$netid'\n"
3eec5767 28 if !defined($netconf);
1e3baf05 29
3eec5767 30my $net = PVE::QemuServer::parse_net($netconf);
1e3baf05
DM
31die "unable to parse network config '$netid'\n" if !$net;
32
56ccc25d 33PVE::Network::tap_create($iface, $net->{bridge});
1e3baf05 34
a279a03d
WL
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
2dd4aa4c 37PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall});
1e3baf05 38
a279a03d
WL
39PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
40
1e3baf05 41exit 0;