Skip to content

Commit 369fb25

Browse files
authored
FR01 - Enable DPDK Support on KVM (#1)
* Enable DPDK support on KVM * Allow DPDK deployments on user VMs only * Fix port name ordering
1 parent 2cb2dac commit 369fb25

23 files changed

Lines changed: 425 additions & 43 deletions

agent/conf/agent.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ domr.scripts.dir=scripts/network/domr/kvm
108108
# openvswitch = com.cloud.hypervisor.kvm.resource.OvsVifDriver
109109
#libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.BridgeVifDriver
110110

111+
# Set DPDK Support on OpenVswitch
112+
#openvswitch.dpdk.enabled=true
113+
#openvswitch.dpdk.ovs.path=/var/run/openvswitch
114+
111115
# set the hypervisor type, values are: kvm, lxc
112116
hypervisor.type=kvm
113117

api/src/com/cloud/agent/api/to/NicTO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class NicTO extends NetworkTO {
3030
String nicUuid;
3131
List<String> nicSecIps;
3232
Map<NetworkOffering.Detail, String> details;
33+
boolean dpdkDisabled;
3334

3435
public NicTO() {
3536
super();
@@ -109,4 +110,12 @@ public Map<NetworkOffering.Detail, String> getDetails() {
109110
public void setDetails(final Map<NetworkOffering.Detail, String> details) {
110111
this.details = details;
111112
}
113+
114+
public boolean isDpdkDisabled() {
115+
return dpdkDisabled;
116+
}
117+
118+
public void setDpdkDisabled(boolean dpdkDisabled) {
119+
this.dpdkDisabled = dpdkDisabled;
120+
}
112121
}

api/src/com/cloud/agent/api/to/VirtualMachineTO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class VirtualMachineTO {
7373
Double cpuQuotaPercentage = null;
7474

7575
Map<String, String> guestOsDetails = new HashMap<String, String>();
76+
Map<String, String> extraConfig = new HashMap<>();
7677

7778
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader,
7879
String os, boolean enableHA, boolean limitCpuUse, String vncPassword) {
@@ -350,4 +351,12 @@ public Double getCpuQuotaPercentage() {
350351
public void setCpuQuotaPercentage(Double cpuQuotaPercentage) {
351352
this.cpuQuotaPercentage = cpuQuotaPercentage;
352353
}
354+
355+
public void addExtraConfig(String key, String value) {
356+
extraConfig.put(key, value);
357+
}
358+
359+
public Map<String, String> getExtraConfig() {
360+
return extraConfig;
361+
}
353362
}

api/src/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public class ApiConstants {
116116
public static final String END_PORT = "endport";
117117
public static final String ENTRY_TIME = "entrytime";
118118
public static final String EXPIRES = "expires";
119+
public static final String EXTRA_CONFIG = "extraconfig";
119120
public static final String EXTRA_DHCP_OPTION = "extradhcpoption";
120121
public static final String EXTRA_DHCP_OPTION_NAME = "extradhcpoptionname";
121122
public static final String EXTRA_DHCP_OPTION_CODE = "extradhcpoptioncode";

api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
200200
" an optional parameter used to create additional data disks from datadisk templates; can't be specified with diskOfferingId parameter")
201201
private Map dataDiskTemplateToDiskOfferingList;
202202

203+
@Parameter(name = ApiConstants.EXTRA_CONFIG, type = CommandType.STRING, since = "4.11.1", description = "an optional URL encoded string that can be passed to the virtual machine upon successful deployment", length = 5120)
204+
private String extraConfig;
205+
203206
/////////////////////////////////////////////////////
204207
/////////////////// Accessors ///////////////////////
205208
/////////////////////////////////////////////////////
@@ -482,6 +485,10 @@ public Map<Long, DiskOffering> getDataDiskTemplateToDiskOfferingMap() {
482485
return dataDiskTemplateToDiskOfferingMap;
483486
}
484487

488+
public String getExtraConfig() {
489+
return extraConfig;
490+
}
491+
485492
/////////////////////////////////////////////////////
486493
/////////////// API Implementation///////////////////
487494
/////////////////////////////////////////////////////

api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public class UpdateVMCmd extends BaseCustomIdCmd implements SecurityGroupAction
128128
+ " Example: dhcpoptionsnetworklist[0].dhcp:114=url&dhcpoptionsetworklist[0].networkid=networkid&dhcpoptionsetworklist[0].dhcp:66=www.test.com")
129129
private Map dhcpOptionsNetworkList;
130130

131+
@Parameter(name = ApiConstants.EXTRA_CONFIG, type = CommandType.STRING, since = "4.11.1", description = "an optional URL encoded string that can be passed to the virtual machine upon successful deployment", authorized = { RoleType.Admin }, length = 5120)
132+
private String extraConfig;
131133

132134
/////////////////////////////////////////////////////
133135
/////////////////// Accessors ///////////////////////
@@ -221,6 +223,10 @@ public Map<String, Map<Integer, String>> getDhcpOptionsMap() {
221223
return dhcpOptionsMap;
222224
}
223225

226+
public String getExtraConfig() {
227+
return extraConfig;
228+
}
229+
224230
/////////////////////////////////////////////////////
225231
/////////////// API Implementation///////////////////
226232
/////////////////////////////////////////////////////

engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import javax.inject.Inject;
4040
import javax.naming.ConfigurationException;
4141

42+
import org.apache.cloudstack.api.ApiConstants;
4243
import org.apache.commons.collections.CollectionUtils;
4344
import org.apache.log4j.Logger;
4445

@@ -1131,6 +1132,8 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
11311132

11321133
vmGuru.finalizeDeployment(cmds, vmProfile, dest, ctx);
11331134

1135+
addExtraConfig(vmTO);
1136+
11341137
work = _workDao.findById(work.getId());
11351138
if (work == null || work.getStep() != Step.Prepare) {
11361139
throw new ConcurrentOperationException("Work steps have been changed: " + work);
@@ -1295,6 +1298,15 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
12951298
}
12961299
}
12971300

1301+
private void addExtraConfig(VirtualMachineTO vmTO) {
1302+
Map<String, String> details = vmTO.getDetails();
1303+
for (String key : details.keySet()) {
1304+
if (key.startsWith(ApiConstants.EXTRA_CONFIG)) {
1305+
vmTO.addExtraConfig(key, details.get(key));
1306+
}
1307+
}
1308+
}
1309+
12981310
// for managed storage on KVM, need to make sure the path field of the volume in question is populated with the IQN
12991311
private void handlePath(final DiskTO[] disks, final HypervisorType hypervisorType) {
13001312
if (hypervisorType != HypervisorType.KVM) {

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private static boolean isInterface(final String fname) {
207207
}
208208

209209
@Override
210-
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter) throws InternalErrorException, LibvirtException {
210+
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
211211

212212
if (s_logger.isDebugEnabled()) {
213213
s_logger.debug("nic=" + nic);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import com.cloud.exception.InternalErrorException;
2727
import com.cloud.network.Networks;
2828

29+
import java.util.Map;
30+
2931
public class DirectVifDriver extends VifDriverBase {
3032

3133
private static final Logger s_logger = Logger.getLogger(DirectVifDriver.class);
@@ -36,12 +38,13 @@ public class DirectVifDriver extends VifDriverBase {
3638
*
3739
* @param nic
3840
* @param guestOsType
41+
* @param extraConfig
3942
* @return
4043
* @throws InternalErrorException
4144
* @throws LibvirtException
4245
*/
4346
@Override
44-
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter) throws InternalErrorException, LibvirtException {
47+
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
4548
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
4649

4750
if (nic.getType() == Networks.TrafficType.Guest) {

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/IvsVifDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void configure(Map<String, Object> params) throws ConfigurationException
7777
}
7878

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

8383
String vNetId = null;

0 commit comments

Comments
 (0)