Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
String trafficLabel = nic.getName();
Integer networkRateKBps = 0;
if (libvirtVersion > ((10 * 1000 + 10))) {
networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
networkRateKBps = getNetworkRateKbps(nic);
}

if (nic.getType() == Networks.TrafficType.Guest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

public class DirectVifDriver extends VifDriverBase {


/**
* Experimental driver to configure direct networking in libvirt. This should only
* be used on an LXC cluster that does not run any system VMs.
Expand All @@ -42,13 +41,14 @@ public class DirectVifDriver extends VifDriverBase {
* @throws InternalErrorException
* @throws LibvirtException
*/

@Override
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();

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;
Integer networkRateKBps = getNetworkRateKbps(nic);
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<S
vlanId = NetUtils.getPrimaryPvlanFromUri(nic.getBroadcastUri());
}
String trafficLabel = nic.getName();
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
Integer networkRateKBps = getNetworkRateKbps(nic);
if (nic.getType() == Networks.TrafficType.Guest) {
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) &&
!vlanId.equalsIgnoreCase("untagged")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<S
}
String trafficLabel = nic.getName();
if (nic.getType() == Networks.TrafficType.Guest) {
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
Integer networkRateKBps = getNetworkRateKbps(nic);
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) &&
!vlanId.equalsIgnoreCase("untagged")) {
if (trafficLabel != null && !trafficLabel.isEmpty()) {
Expand Down Expand Up @@ -162,7 +162,7 @@ public InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<S
createControlNetwork(_bridges.get("linklocal"));
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter));
} else if (nic.getType() == Networks.TrafficType.Public) {
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
Integer networkRateKBps = getNetworkRateKbps(nic);
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vlanId.equalsIgnoreCase("untagged")) {
if (trafficLabel != null && !trafficLabel.isEmpty()) {
logger.debug("creating a vlan dev and bridge for public traffic per traffic label " + trafficLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public abstract class VifDriverBase implements VifDriver {
protected Map<String, String> _pifs;
protected Map<String, String> _bridges;

protected static final int bitsPerMbpsToKbps = 125;

@Override
public void configure(Map<String, Object> params) throws ConfigurationException {
_libvirtComputingResource = (LibvirtComputingResource)params.get("libvirt.computing.resource");
Expand Down Expand Up @@ -78,4 +80,11 @@ protected LibvirtVMDef.InterfaceDef.NicModel getGuestNicModel(String platformEmu
public boolean isExistingBridge(String bridgeName) {
return false;
}

protected static int getNetworkRateKbps(NicTO nic) {
if (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) {
return nic.getNetworkRateMbps().intValue() * bitsPerMbpsToKbps;
}
return 0;
}
}
Loading