mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-9211: Support passing vRAM size to support 3D GPU on Vmware
This commit is contained in:
parent
ee2ccc4d41
commit
656ae10937
@ -94,6 +94,7 @@ import com.vmware.vim25.VirtualMachinePowerState;
|
|||||||
import com.vmware.vim25.VirtualMachineRelocateSpec;
|
import com.vmware.vim25.VirtualMachineRelocateSpec;
|
||||||
import com.vmware.vim25.VirtualMachineRelocateSpecDiskLocator;
|
import com.vmware.vim25.VirtualMachineRelocateSpecDiskLocator;
|
||||||
import com.vmware.vim25.VirtualMachineRuntimeInfo;
|
import com.vmware.vim25.VirtualMachineRuntimeInfo;
|
||||||
|
import com.vmware.vim25.VirtualMachineVideoCard;
|
||||||
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
|
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||||
@ -1895,6 +1896,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
postDiskConfigBeforeStart(vmMo, vmSpec, sortedDisks, ideControllerKey, scsiControllerKey, iqnToPath, hyperHost, context);
|
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
|
||||||
|
postVideoCardMemoryConfigBeforeStart(vmMo, vmSpec);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Power-on VM
|
// Power-on VM
|
||||||
//
|
//
|
||||||
@ -1943,6 +1947,44 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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{
|
private void tearDownVm(VirtualMachineMO vmMo) throws Exception{
|
||||||
|
|
||||||
if(vmMo == null) return;
|
if(vmMo == null) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user