Skip to content

Commit 143b72d

Browse files
authored
cleanup: Network Throttling for Additional Networks code in DirectVifDriver.java (apache#5875)
1 parent b275c29 commit 143b72d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/DirectVifDriver.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package com.cloud.hypervisor.kvm.resource;
2121

22+
import org.apache.commons.compress.utils.Sets;
2223
import org.apache.log4j.Logger;
2324
import org.libvirt.LibvirtException;
2425

@@ -47,12 +48,8 @@ public class DirectVifDriver extends VifDriverBase {
4748
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
4849
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
4950

50-
if (nic.getType() == Networks.TrafficType.Guest) {
51-
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
52-
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
53-
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);
54-
55-
} else if (nic.getType() == Networks.TrafficType.Public) {
51+
if (Sets.newHashSet(Networks.TrafficType.Guest,
52+
Networks.TrafficType.Public).contains(nic.getType())) {
5653
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
5754
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
5855
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);

0 commit comments

Comments
 (0)