]> git.proxmox.com Git - qemu-server.git/blobdiff - pve-bridge
use property strings for drive options
[qemu-server.git] / pve-bridge
index d6c5eb8732a8a1a753307dff889259f744576ac9..c23c6439d9e3cc16a3f8ee83dad87ace81fb1e4a 100755 (executable)
@@ -8,6 +8,12 @@ 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" 
@@ -16,20 +22,26 @@ die "got strange interface name '$iface'\n"
 my $vmid = $1;
 my $netid = "net$2";
 
-my $migratedfrom = $ENV{PVE_MIGRATED_FROM};
+my $migratedfrom = $hotplug ? undef : $ENV{PVE_MIGRATED_FROM};
 
 my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom);
 
+my $netconf = $conf->{$netid};
+
+$netconf = $conf->{pending}->{$netid} if !$migratedfrom && defined($conf->{pending}->{$netid}); 
 die "unable to get network config '$netid'\n"
-    if !$conf->{$netid};
+    if !defined($netconf);
 
-my $net = PVE::QemuServer::parse_net($conf->{$netid});
+my $net = PVE::QemuServer::parse_net($netconf);
 die "unable to parse network config '$netid'\n" if !$net;
 
 PVE::Network::tap_create($iface, $net->{bridge});
 
-PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
-
+# 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});
 
+PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
+
 exit 0;