]> git.proxmox.com Git - qemu-server.git/blame - pve-bridge
qemu_machine_pxe : return $machine if no pxe
[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
50669ed5
WB
11my $hotplug = 0;
12if ($iface eq '--hotplug') {
13 $hotplug = 1;
14 $iface = shift;
15}
16
1e3baf05
DM
17die "no interface specified\n" if !$iface;
18
19die "got strange interface name '$iface'\n"
20 if $iface !~ m/^tap(\d+)i(\d+)$/;
21
22my $vmid = $1;
23my $netid = "net$2";
24
50669ed5 25my $migratedfrom = $hotplug ? undef : $ENV{PVE_MIGRATED_FROM};
d691e6d3
DM
26
27my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom);
1e3baf05 28
3eec5767
DM
29my $netconf = $conf->{$netid};
30
31$netconf = $conf->{pending}->{$netid} if !$migratedfrom && defined($conf->{pending}->{$netid});
32
1e3baf05 33die "unable to get network config '$netid'\n"
3eec5767 34 if !defined($netconf);
1e3baf05 35
3eec5767 36my $net = PVE::QemuServer::parse_net($netconf);
1e3baf05
DM
37die "unable to parse network config '$netid'\n" if !$net;
38
56ccc25d 39PVE::Network::tap_create($iface, $net->{bridge});
1e3baf05 40
a279a03d
WL
41# if ovs is under this bridge all traffic control settings will be flushed.
42# so we need to call tap_rate_limit after tap_plug
c30aea2b 43PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall}, $net->{trunks});
1e3baf05 44
a279a03d
WL
45PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
46
1e3baf05 47exit 0;