5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-03-11 16:58:28 +03:00
qemu-server/pve-bridge

48 lines
1.1 KiB
Plaintext
Raw Normal View History

2013-10-01 13:14:49 +02:00
#!/usr/bin/perl
2011-08-23 07:47:04 +02:00
use strict;
2013-10-01 13:14:49 +02:00
use warnings;
2011-08-23 07:47:04 +02:00
use PVE::QemuServer;
use PVE::Tools qw(run_command);
use PVE::Network;
2011-08-23 07:47:04 +02:00
my $iface = shift;
2015-11-13 16:16:01 +01:00
my $hotplug = 0;
if ($iface eq '--hotplug') {
$hotplug = 1;
$iface = shift;
}
2011-08-23 07:47:04 +02:00
die "no interface specified\n" if !$iface;
die "got strange interface name '$iface'\n"
if $iface !~ m/^tap(\d+)i(\d+)$/;
my $vmid = $1;
my $netid = "net$2";
2015-11-13 16:16:01 +01:00
my $migratedfrom = $hotplug ? undef : $ENV{PVE_MIGRATED_FROM};
my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom);
2011-08-23 07:47:04 +02:00
my $netconf = $conf->{$netid};
$netconf = $conf->{pending}->{$netid} if !$migratedfrom && defined($conf->{pending}->{$netid});
2011-08-23 07:47:04 +02:00
die "unable to get network config '$netid'\n"
if !defined($netconf);
2011-08-23 07:47:04 +02:00
my $net = PVE::QemuServer::parse_net($netconf);
2011-08-23 07:47:04 +02:00
die "unable to parse network config '$netid'\n" if !$net;
PVE::Network::tap_create($iface, $net->{bridge});
2011-08-23 07:47:04 +02:00
# if ovs is under this bridge all traffic control settings will be flushed.
# so we need to call tap_rate_limit after tap_plug
PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall});
2011-08-23 07:47:04 +02:00
PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
2011-08-23 07:47:04 +02:00
exit 0;