Skip to content
Open
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
9 changes: 9 additions & 0 deletions api/src/main/java/com/cloud/agent/api/to/NicTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class NicTO extends NetworkTO {
boolean enabled;

String networkSegmentName;
private Integer multiqueueNumber;

boolean trunkVlan;
List<NetworkTO> associatedNetworks;
Expand Down Expand Up @@ -183,4 +184,12 @@ public List<NetworkTO> getAssociatedNetworks() {
public void setAssociatedNetworks(List<NetworkTO> associatedNetworks) {
this.associatedNetworks = associatedNetworks;
}

public Integer getMultiqueueNumber() {
return multiqueueNumber;
}

public void setMultiqueueNumber(Integer multiqueueNumber) {
this.multiqueueNumber = multiqueueNumber;
}
}
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/network/vpc/VpcOffering.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ public enum State {
boolean isConserveMode();

Integer getPublicNetworkRate();

Integer getPublicMultiqueueNumber();

Integer getPrivateGatewayMultiqueueNumber();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ VpcOffering createVpcOffering(String name, String displayText, List<String> supp
Map serviceCapabilitystList, NetUtils.InternetProtocol internetProtocol,
Long serviceOfferingId, String externalProvider, NetworkOffering.NetworkMode networkMode,
List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state,
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber, boolean conserveMode, Integer publicNetworkRate);
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber, boolean conserveMode,
Integer publicNetworkRate, Integer publicMultiqueueNumber, Integer privateGatewayMultiqueueNumber);


Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(ListVPCOfferingsCmd cmd);
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/offering/NetworkOffering.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@ enum RoutingMode {
RoutingMode getRoutingMode();

Boolean isSpecifyAsNumber();

Integer getPublicMultiqueueNumber();

Integer getPrivateMultiqueueNumber();
}
9 changes: 9 additions & 0 deletions api/src/main/java/com/cloud/vm/NicProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class NicProfile implements InternalIdentity, Serializable {
boolean enabled;

Integer orderIndex;
private Integer multiqueueNumber;

// IPv4
String iPv4Address;
Expand Down Expand Up @@ -424,6 +425,14 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public Integer getMultiqueueNumber() {
return multiqueueNumber;
}

public void setMultiqueueNumber(Integer multiqueueNumber) {
this.multiqueueNumber = multiqueueNumber;
}

//
// OTHER METHODS
//
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,10 @@ public class ApiConstants {
public static final String BACKUP_PROVIDER = "backupprovider";
public static final String COMPRESS_ASYNC = "compressasync";

public static final String PRIVATE_MULTIQUEUE_NUMBER = "privatemultiqueuenumber";
public static final String PUBLIC_MULTIQUEUE_NUMBER = "publicmultiqueuenumber";
public static final String PRIVATE_GATEWAY_MULTIQUEUE_NUMBER = "privategatewaymultiqueuenumber";

/**
* This enum specifies IO Drivers, each option controls specific policies on I/O.
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ public abstract class NetworkOfferingBaseCmd extends BaseCmd {
description = "the routing mode for the network offering. Supported types are: Static or Dynamic.")
private String routingMode;

@Parameter(name = ApiConstants.PUBLIC_MULTIQUEUE_NUMBER, type = CommandType.INTEGER, since = "24.0",
description = "Multiqueue number for the public NIC of VRs belonging to guest networks. This parameter " +
"is not allowed for L2 network and isolated network for VPC (tier) offerings.")
private Integer publicMultiqueueNumber;

@Parameter(name = ApiConstants.PRIVATE_MULTIQUEUE_NUMBER, type = CommandType.INTEGER, since = "24.0",
description = "Multiqueue number for the private NICs of VRs belonging to guest networks and VPC tiers. " +
"This parameter is not allowed for L2 network offerings")
private Integer privateMultiqueueNumber;

private Map<String, String> sourceDetailsMap;

/////////////////////////////////////////////////////
Expand Down Expand Up @@ -492,6 +502,14 @@ public String getRoutingMode() {
return routingMode;
}

public Integer getPublicMultiqueueNumber() {
return publicMultiqueueNumber;
}

public Integer getPrivateMultiqueueNumber() {
return privateMultiqueueNumber;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
description = "Data transfer rate in megabits per second allowed for a VPC's public gateway (internet-facing network), created with this offering. Use -1 for unlimited. If not specified, VPCs created with this offering use the zone level setting vpc.public.network.throttling.rate")
private Integer publicNetworkRate;

@Parameter(name = ApiConstants.PUBLIC_MULTIQUEUE_NUMBER, type = CommandType.INTEGER, since = "24.0",
description = "Multiqueue number for the public NIC of VRs belonging to VPCs.")
private Integer publicMultiqueueNumber;

@Parameter(name = ApiConstants.PRIVATE_GATEWAY_MULTIQUEUE_NUMBER, type = CommandType.INTEGER, since = "24.0",
description = "Multiqueue number for the private gateway NIC of VRs belonging to VPCs.")
private Integer privateGatewayMultiqueueNumber;


/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
Expand Down Expand Up @@ -347,6 +355,14 @@ public Integer getPublicNetworkRate() {
return publicNetworkRate;
}

public Integer getPublicMultiqueueNumber() {
return publicMultiqueueNumber;
}

public Integer getPrivateGatewayMultiqueueNumber() {
return privateGatewayMultiqueueNumber;
}

@Override
public void create() throws ResourceAllocationException {
VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ public class NetworkOfferingResponse extends BaseResponseWithAnnotations {
@Param(description = "the routing mode for the network offering, supported types are Static or Dynamic.")
private String routingMode;

@SerializedName(ApiConstants.PUBLIC_MULTIQUEUE_NUMBER)
@Param(description = "Multiqueue number for the public NIC of VRs belonging to isolated networks.", since = "24.0")
private Integer publicMultiqueueNumber;

@SerializedName(ApiConstants.PRIVATE_MULTIQUEUE_NUMBER)
@Param(description = "Multiqueue number for the private NICs of VRs belonging to isolated networks and VPC tiers.", since = "24.0")
private Integer privateMultiqueueNumber;

public void setId(String id) {
this.id = id;
}
Expand Down Expand Up @@ -342,4 +350,12 @@ public String getServiceOfferingName() {
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}

public void setPublicMultiqueueNumber(Integer publicMultiqueueNumber) {
this.publicMultiqueueNumber = publicMultiqueueNumber;
}

public void setPrivateMultiqueueNumber(Integer privateMultiqueueNumber) {
this.privateMultiqueueNumber = privateMultiqueueNumber;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public class VpcOfferingResponse extends BaseResponse {
@Param(description = "Data transfer rate in megabits per second allowed for a VPC's public gateway (internet-facing network), created with this offering; -1 if unlimited. Not returned if no rate is set on the offering, in which case VPCs created with it use the zone level setting vpc.public.network.throttling.rate", since = "24.0.0")
private Integer publicNetworkRate;

@SerializedName(ApiConstants.PUBLIC_MULTIQUEUE_NUMBER)
@Param(description = "Multiqueue number for the public NIC of VRs belonging to VPCs.", since = "24.0")
private Integer publicMultiqueueNumber;

@SerializedName(ApiConstants.PRIVATE_GATEWAY_MULTIQUEUE_NUMBER)
@Param(description = "Multiqueue number for the private gateway NIC of VRs belonging to VPCs.", since = "24.0")
private Integer privateGatewayMultiqueueNumber;

public void setId(String id) {
this.id = id;
}
Expand Down Expand Up @@ -229,4 +237,12 @@ public void setPublicNetworkRate(Integer publicNetworkRate) {
public void setRedundantRouter(Boolean redundantRouter) {
this.redundantRouter = redundantRouter;
}

public void setPublicMultiqueueNumber(Integer publicMultiqueueNumber) {
this.publicMultiqueueNumber = publicMultiqueueNumber;
}

public void setPrivateGatewayMultiqueueNumber(Integer privateGatewayMultiqueueNumber) {
this.privateGatewayMultiqueueNumber = privateGatewayMultiqueueNumber;
}
}
32 changes: 22 additions & 10 deletions core/src/main/java/com/cloud/agent/api/PlugNicCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,12 @@
import java.util.Map;

public class PlugNicCommand extends Command {

NicTO nic;
String instanceName;
VirtualMachine.Type vmType;
private Integer targetVmCpus;
Map<String, String> details;

public NicTO getNic() {
return nic;
}

@Override
public boolean executeInSequence() {
return true;
}

protected PlugNicCommand() {
}

Expand All @@ -56,6 +47,18 @@ public PlugNicCommand(NicTO nic, String instanceName, VirtualMachine.Type vmtype
this.details = details;
}

public PlugNicCommand(NicTO nic, String instanceName, VirtualMachine.Type vmtype, Integer targetVmCpus, Map<String, String> details) {
this.nic = nic;
this.instanceName = instanceName;
this.vmType = vmtype;
this.targetVmCpus = targetVmCpus;
this.details = details;
}

public NicTO getNic() {
return nic;
}

public String getVmName() {
return instanceName;
}
Expand All @@ -67,4 +70,13 @@ public VirtualMachine.Type getVMType() {
public Map<String, String> getDetails() {
return this.details;
}

public Integer getTargetVmCpus() {
return targetVmCpus;
}

@Override
public boolean executeInSequence() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
Expand Down Expand Up @@ -144,6 +145,57 @@ public interface NetworkOrchestrationService {
ConfigKey<Integer> VpcPublicNetworkThrottlingRate = new ConfigKey<>("Network", Integer.class, "vpc.public.network.throttling.rate", "-1",
"Default data transfer rate in megabits per second allowed for a VPC's public/internet-facing network, used when the VPC offering does not specify a rate. -1 means unlimited.", true, ConfigKey.Scope.Zone);

int MAX_MULTIQUEUE_NUMBER = 256;

ConfigKey<Integer> RouterNicMultiqueueNumber = new ConfigKey<>(
"Network",
Integer.class,
"router.nic.multiqueue.number",
"1",
"Default number of queues for the NICs of virtual routers (KVM only), used when the corresponding " +
"multiqueue parameter of the network or VPC offering is not set. Accepted values are -1 (one queue per " +
"VR vCPU) or an integer from 1 to " + MAX_MULTIQUEUE_NUMBER + ". When unset, multiqueue is defined as 1.",
true,
Scope.Global);

/**
* Returns the multiqueue number to be used for a VR NIC: the value defined in the network/VPC offering, if any;
* otherwise, the value of {@link #RouterNicMultiqueueNumber}.
*/
static Integer getRouterNicMultiqueueNumber(Integer offeringMultiqueueNumber) {
return offeringMultiqueueNumber != null ? offeringMultiqueueNumber : RouterNicMultiqueueNumber.value();
}

/**
* Validates a multiqueue number informed through an API parameter. Null values are ignored.
* @throws InvalidParameterValueException if the value is neither -1 nor an integer from 1 to {@link #MAX_MULTIQUEUE_NUMBER}.
*/
static void validateMultiqueueNumberParameter(Integer value, String parameterName) {
validateMultiqueueNumber(value, "parameter", parameterName);
}

/**
* Validates a multiqueue number informed through a configuration. Null values are ignored.
* @throws InvalidParameterValueException if the value is neither -1 nor an integer from 1 to {@link #MAX_MULTIQUEUE_NUMBER}.
*/
static void validateMultiqueueNumberConfiguration(Integer value, String configurationName) {
validateMultiqueueNumber(value, "configuration", configurationName);
}

private static void validateMultiqueueNumber(Integer value, String type, String name) {
if (value == null) {
return;
}

if (value <= 0 && value != -1) {
throw new InvalidParameterValueException(String.format("The only non-positive value accepted by the %s [%s] is [-1].", type, name));
}

if (value > MAX_MULTIQUEUE_NUMBER) {
throw new InvalidParameterValueException(String.format("[%s] %s cannot be greater than %d.", name, type, MAX_MULTIQUEUE_NUMBER));
}
}

List<? extends Network> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
throws ConcurrentOperationException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ NetworkOfferingVO createNetworkOffering(String name, String displayText, Traffic
boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent,
Map<NetworkOffering.Detail, String> details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive, Boolean forVpc,
Boolean forTungsten, boolean forNsx, boolean forNetris, NetworkOffering.NetworkMode networkMode, List<Long> domainIds, List<Long> zoneIds, boolean enableOffering, final NetUtils.InternetProtocol internetProtocol,
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber);
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber, Integer publicMultiqueueNumber, Integer privateMultiqueueNumber);

Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, boolean forSystemVms, Long podId, String startIP, String endIP,
String vlanGateway, String vlanNetmask, String vlanId, boolean bypassVlanOverlapCheck, Domain domain, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr, Provider provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5206,8 +5206,8 @@ public boolean plugNic(final Network network, final NicTO nic, final VirtualMach
ResourceUnavailableException, InsufficientCapacityException {
boolean result = true;

final VMInstanceVO router = _vmDao.findById(vm.getId());
if (router.getState() == State.Running) {
final VMInstanceVO targetVm = _vmDao.findById(vm.getId());
if (targetVm.getState() == State.Running) {
try {
NetworkDetailVO pvlanTypeDetail = networkDetailsDao.findDetail(network.getId(), ApiConstants.ISOLATED_PVLAN_TYPE);
if (pvlanTypeDetail != null) {
Expand All @@ -5216,7 +5216,7 @@ public boolean plugNic(final Network network, final NicTO nic, final VirtualMach
nicDetails.putIfAbsent(NetworkOffering.Detail.pvlanType, pvlanTypeDetail.getValue());
nic.setDetails(nicDetails);
}
final PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType(), vm.getDetails());
final PlugNicCommand plugNicCmd = new PlugNicCommand(nic, vm.getName(), vm.getType(), vm.getCpus(), vm.getDetails());
final Commands cmds = new Commands(Command.OnError.Stop);
cmds.addCommand("plugnic", plugNicCmd);
_agentMgr.send(dest.getHost().getId(), cmds);
Expand All @@ -5229,11 +5229,11 @@ public boolean plugNic(final Network network, final NicTO nic, final VirtualMach
throw new AgentUnavailableException("Unable to plug nic for router " + vm.getName() + " in network " + network, dest.getHost().getId(), e);
}
} else {
String message = String.format("Unable to apply PlugNic, VM [%s] is not in the right state (\"Running\"). VM state [%s].", router.toString(), router.getState());
String message = String.format("Unable to plug NIC to VM [%s], as it is not in the right state (\"Running\"). VM state [%s].", targetVm, targetVm.getState());
logger.warn(message);

throw new ResourceUnavailableException(message, DataCenter.class,
router.getDataCenterId());
targetVm.getDataCenterId());
}

return result;
Expand Down
Loading
Loading