cleanup: Network Throttling for Additional Networks code in DirectVifDriver.java (#5875)

This commit is contained in:
dahn 2022-02-09 10:19:47 +01:00 committed by GitHub
parent b275c29709
commit 143b72d67e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@
package com.cloud.hypervisor.kvm.resource;
import org.apache.commons.compress.utils.Sets;
import org.apache.log4j.Logger;
import org.libvirt.LibvirtException;
@ -47,12 +48,8 @@ public class DirectVifDriver extends VifDriverBase {
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
if (nic.getType() == Networks.TrafficType.Guest) {
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);
} else if (nic.getType() == Networks.TrafficType.Public) {
if (Sets.newHashSet(Networks.TrafficType.Guest,
Networks.TrafficType.Public).contains(nic.getType())) {
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);