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_r153313022
 
 

 ##########
 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:
   Is it possible for this `pciPassthroughDevice ` to be null after the 
previous IF/ELSE?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to