GutoVeronezi commented on a change in pull request #5875:
URL: https://github.com/apache/cloudstack/pull/5875#discussion_r792578407



##########
File path: 
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/DirectVifDriver.java
##########
@@ -47,12 +47,7 @@
     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 (nic.getType() == Networks.TrafficType.Guest || nic.getType() == 
Networks.TrafficType.Public) {

Review comment:
       We could create a static `Set`, add the types 
`Networks.TrafficType.Guest` and `Networks.TrafficType.Public`, and then verify 
if the set contains the `nic.getType()`. This way we can avoid long statements, 
as, if we need add another type, we just have to add it in the `Set`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to