@@ -46,6 +46,7 @@ public class BridgeVifDriver extends VifDriverBase {
4646 private String _modifyVlanPath ;
4747 private String _modifyVxlanPath ;
4848 private String bridgeNameSchema ;
49+ private Long libvirtVersion ;
4950
5051 @ Override
5152 public void configure (Map <String , Object > params ) throws ConfigurationException {
@@ -74,6 +75,11 @@ public void configure(Map<String, Object> params) throws ConfigurationException
7475 throw new ConfigurationException ("Unable to find modifyvxlan.sh" );
7576 }
7677
78+ libvirtVersion = (Long ) params .get ("libvirtVersion" );
79+ if (libvirtVersion == null ) {
80+ libvirtVersion = 0L ;
81+ }
82+
7783 try {
7884 createControlNetwork ();
7985 } catch (LibvirtException e ) {
@@ -102,8 +108,12 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
102108 throw new InternalErrorException ("Nicira NVP Logicalswitches are not supported by the BridgeVifDriver" );
103109 }
104110 String trafficLabel = nic .getName ();
111+ Integer networkRateKBps = 0 ;
112+ if (libvirtVersion > ((10 * 1000 + 10 ))) {
113+ networkRateKBps = (nic .getNetworkRateMbps () != null && nic .getNetworkRateMbps ().intValue () != -1 ) ? nic .getNetworkRateMbps ().intValue () * 128 : 0 ;
114+ }
115+
105116 if (nic .getType () == Networks .TrafficType .Guest ) {
106- Integer networkRateKBps = (nic .getNetworkRateMbps () != null && nic .getNetworkRateMbps ().intValue () != -1 ) ? nic .getNetworkRateMbps ().intValue () * 128 : 0 ;
107117 if ((nic .getBroadcastType () == Networks .BroadcastDomainType .Vlan ) && (vNetId != null ) && (protocol != null ) && (!vNetId .equalsIgnoreCase ("untagged" )) ||
108118 (nic .getBroadcastType () == Networks .BroadcastDomainType .Vxlan )) {
109119 if (trafficLabel != null && !trafficLabel .isEmpty ()) {
@@ -122,7 +132,6 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
122132 createControlNetwork ();
123133 intf .defBridgeNet (_bridges .get ("linklocal" ), null , nic .getMac (), getGuestNicModel (guestOsType , nicAdapter ));
124134 } else if (nic .getType () == Networks .TrafficType .Public ) {
125- Integer networkRateKBps = (nic .getNetworkRateMbps () != null && nic .getNetworkRateMbps ().intValue () != -1 ) ? nic .getNetworkRateMbps ().intValue () * 128 : 0 ;
126135 if ((nic .getBroadcastType () == Networks .BroadcastDomainType .Vlan ) && (vNetId != null ) && (protocol != null ) && (!vNetId .equalsIgnoreCase ("untagged" )) ||
127136 (nic .getBroadcastType () == Networks .BroadcastDomainType .Vxlan )) {
128137 if (trafficLabel != null && !trafficLabel .isEmpty ()) {
0 commit comments