]> git.proxmox.com Git - qemu-server.git/blobdiff - pve-bridge
d/control: remove unused dependency
[qemu-server.git] / pve-bridge
index fdee9201b3f0df9e242e57fb85d37043dcba231d..64490b0a9b70278fc22e4a22c4c8007758457663 100755 (executable)
@@ -1,12 +1,19 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 use PVE::QemuServer;
 use PVE::Tools qw(run_command);
 use PVE::Network;
 
 my $iface = shift;
 
+my $hotplug = 0;
+if ($iface eq '--hotplug') {
+    $hotplug = 1;
+    $iface = shift;
+}
+
 die "no interface specified\n" if !$iface;
 
 die "got strange interface name '$iface'\n" 
@@ -15,33 +22,22 @@ die "got strange interface name '$iface'\n"
 my $vmid = $1;
 my $netid = "net$2";
 
-my $conf = PVE::QemuServer::load_config ($vmid);
-
-die "unable to get network config '$netid'\n"
-    if !$conf->{$netid};
-
-my $net = PVE::QemuServer::parse_net($conf->{$netid});
-die "unable to parse network config '$netid'\n" if !$net;
-
-my $bridge = $net->{bridge};
-die "unable to get bridge setting\n" if !$bridge;
+my $migratedfrom = $hotplug ? undef : $ENV{PVE_MIGRATED_FROM};
 
-system ("/sbin/ifconfig $iface 0.0.0.0 promisc up") == 0 ||
-    die "interface activation failed\n";
+my $conf = PVE::QemuConfig->load_config($vmid, $migratedfrom);
 
-if ($net->{rate}) {
+my $netconf = $conf->{$netid};
 
-    my $debug = 0;
-    my $rate = int($net->{rate}*1024*1024);
-    my $burst = 1024*1024;
+$netconf = $conf->{pending}->{$netid} if !$migratedfrom && defined($conf->{pending}->{$netid}); 
+die "unable to get network config '$netid'\n"
+    if !defined($netconf);
 
-    PVE::Network::setup_tc_rate_limit($iface, $rate, $burst, $debug);
-}
+my $net = PVE::QemuServer::parse_net($netconf);
+die "unable to parse network config '$netid'\n" if !$net;
 
-my $newbridge = PVE::Network::activate_bridge_vlan($bridge, $net->{tag});
-PVE::Network::copy_bridge_config($bridge, $newbridge) if $bridge ne $newbridge;
+PVE::Network::tap_create($iface, $net->{bridge});
 
-system ("/usr/sbin/brctl addif $newbridge $iface") == 0 ||
-    die "can't add interface to bridge\n";
+PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall}, $net->{trunks}, $net->{rate});
 
 exit 0;