[ https://issues.apache.org/jira/browse/CLOUDSTACK-10106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16268873#comment-16268873 ]
ASF GitHub Bot commented on CLOUDSTACK-10106: --------------------------------------------- rafaelweingartner commented on a change in pull request #2340: CLOUDSTACK-10106: GPU/vGPU Support on VMWare URL: https://github.com/apache/cloudstack/pull/2340#discussion_r153519413 ########## File path: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java ########## @@ -2254,6 +2270,46 @@ protected void configureVideoCard(VirtualMachineMO vmMo, VirtualMachineTO vmSpec } } + /** + * Sets GPU card details to the one provided in detail vgpu.type (if provided) on {@code vmConfigSpec}. + * @param vmMo + * @param vmSpec + * @param vmConfigSpec + * @throws RuntimeFaultFaultMsg + * @throws Exception + */ + protected void configureGpuCard(final VirtualMachineMO vmMo, final VirtualMachineTO vmSpec, final VirtualMachineConfigSpec vmConfigSpec) throws Exception { + final String vGpuProfile = vmSpec.getGpuDevice().getVgpuType(); + + VirtualDevice pciPassthroughDevice = null; + HostMO hostMo = new HostMO(vmMo.getContext(), getHyperHost(vmMo.getContext()).getMor()); + + if (vGpuProfile.equalsIgnoreCase(GPU.GPUType.passthrough.toString())) { + // Fetch the available direct PCI graphics card available for allocation + String pciDeviceId = hostMo.getPciIdForAvailableDirectPciPassthroughDevice(); + VirtualMachinePciPassthroughInfo hostPciDeviceInfo = hostMo.getHostPciDeviceInfo(pciDeviceId); + + if (hostPciDeviceInfo == null) { + final String msg = "Unable to find free passthrough GPU to be allocated to VM. Please check the host hardware configuration."; + s_logger.error(msg); + throw new Exception(msg); + } + + pciPassthroughDevice = hostMo.prepareDirectPciPassthroughDevice(hostPciDeviceInfo); + } else { + pciPassthroughDevice = hostMo.prepareSharedPciPassthroughDevice(vGpuProfile); + } + + if (pciPassthroughDevice != null) { Review comment: Well, I understand the idea to code avoiding/deflecting null pointer exceptions. However, cases like this when it is not possible to happen a null pointer exception. I would not do the check/conditional; otherwise, it feels that for every time we use an object we would have to add a conditional checking if that object is a null value or not. I would not force (suggest strongly) you to remove this because it does not harm the code, but I called your attention to this matter. I know that it might seem nice that we are deflecting null pointers, but if they do not happen at all, we are not deflecting anything ;) It is a personal choice (so the power is yours here). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > GPU/vGPU Support on VMWare > -------------------------- > > Key: CLOUDSTACK-10106 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10106 > Project: CloudStack > Issue Type: New Feature > Security Level: Public(Anyone can view this level - this is the > default.) > Components: API, UI, VMware > Affects Versions: 4.11.0.0 > Reporter: Nitin Kumar Maharana > Labels: VMWARE > Fix For: 4.11.0.0 > > > VMware has added support for NVIDIA GRID K1 and NVIDIA GRID K2 cards as well > as NVIDIA Tesla M6 and Tesla M60 cards. This feature allows CloudStack VMs on > ESXi hosts to use the GPU cards connected to it. Currently, it supports only > NVIDIA GRID K1 and K2 cards for CloudStack VMs. > Feature Specification: > https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=74681765 -- This message was sent by Atlassian JIRA (v6.4.14#64029)