Skip to content
Merged
Changes from 1 commit
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
Next Next commit
CLOUDSTACK-9211: Support passing vRAM size to support 3D GPU on Vmware
  • Loading branch information
nvazquez committed Jan 5, 2016
commit 656ae109377e7d4400d16f05cbb4096e20a8c05b
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import com.vmware.vim25.VirtualMachineRelocateSpec;
import com.vmware.vim25.VirtualMachineRelocateSpecDiskLocator;
import com.vmware.vim25.VirtualMachineRuntimeInfo;
import com.vmware.vim25.VirtualMachineVideoCard;
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;

import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
Expand Down Expand Up @@ -1895,6 +1896,9 @@ protected StartAnswer execute(StartCommand cmd) {

postDiskConfigBeforeStart(vmMo, vmSpec, sortedDisks, ideControllerKey, scsiControllerKey, iqnToPath, hyperHost, context);

//Sets video card memory to the one provided in detail svga.vramSize (if provided), 64MB was always set before
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a comment like this would be better located in a Javadoc style comment above the postVideoCardMemoryConfigBeforeStart method itself, along with brief descriptions of the parameters involved. This could make it easier to read/understand going forward. :)

postVideoCardMemoryConfigBeforeStart(vmMo, vmSpec);

//
// Power-on VM
//
Expand Down Expand Up @@ -1943,6 +1947,44 @@ protected StartAnswer execute(StartCommand cmd) {
}
}

private void postVideoCardMemoryConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachineTO vmSpec) {
String paramVRamSize = "svga.vramSize";
if (vmSpec.getDetails().containsKey(paramVRamSize)){
String value = vmSpec.getDetails().get(paramVRamSize);
try {
long svgaVmramSize = Long.parseLong(value);
for (VirtualDevice device : vmMo.getAllDeviceList()){
if (device instanceof VirtualMachineVideoCard){
VirtualMachineVideoCard videoCard = (VirtualMachineVideoCard) device;
if (videoCard.getVideoRamSizeInKB().longValue() != svgaVmramSize){
s_logger.info("Video card memory was set " + videoCard.getVideoRamSizeInKB().longValue() + "kb instead of " + svgaVmramSize + "kb");
videoCard.setVideoRamSizeInKB(svgaVmramSize);
videoCard.setUseAutoDetect(false);

VirtualDeviceConfigSpec arrayVideoCardConfigSpecs = new VirtualDeviceConfigSpec();
arrayVideoCardConfigSpecs.setDevice(videoCard);
arrayVideoCardConfigSpecs.setOperation(VirtualDeviceConfigSpecOperation.EDIT);

VirtualMachineConfigSpec changeVideoCardSpecs = new VirtualMachineConfigSpec();
changeVideoCardSpecs.getDeviceChange().add(arrayVideoCardConfigSpecs);

boolean res = vmMo.configureVm(changeVideoCardSpecs);
if (res) {
s_logger.info("Video card memory successfully updated to " + svgaVmramSize + "kb");
}
}
}
}
}
catch (NumberFormatException e){
s_logger.error("Unexpected value, cannot parse " + value + " to long due to: " + e.getMessage());
}
catch (Exception e){
s_logger.error("Error while reconfiguring vm due to: " + e.getMessage());
}
}
}

private void tearDownVm(VirtualMachineMO vmMo) throws Exception{

if(vmMo == null) return;
Expand Down