Feature: Add support for GPU with KVM hosts - #11143
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR allows attaching of GPU devices via PCI, mdev or VF to an Instance for KVM.
CWiki Design doc: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Support+for+GPU+with+KVM+hosts
Doc PR: apache/cloudstack-documentation#526
Generated summary
This pull request introduces several changes across multiple files, focusing on enhancing GPU-related functionality, adding new properties for VM hooks, and updating resource management capabilities. The most significant updates include the addition of GPU properties and event types, the introduction of new VM shell script properties, and modifications to resource limits and types to support GPU devices.
GPU-related enhancements:
api/src/main/java/com/cloud/agent/api/VgpuTypesInfo.java: Added new fields such asdeviceType,busAddress,vendorId, andvmNameto support detailed GPU device information. Also included getter and setter methods for these fields and updated constructors to accommodate the new properties. [1] [2] [3]api/src/main/java/com/cloud/agent/api/to/GPUDeviceTO.java: Introduced new fields likegpuCountandgpuDevicesto manage GPU device details and added corresponding getter/setter methods. Updated constructors to handle the new fields. [1] [2] [3]api/src/main/java/com/cloud/event/EventTypes.java: Added new GPU-related event types (EVENT_GPU_CARD_CREATE,EVENT_VGPU_PROFILE_CREATE, etc.) and mapped them to corresponding entities such asGpuCardandVgpuProfile. [1] [2]VM hook properties:
agent/src/main/java/com/cloud/agent/properties/AgentProperties.java: Added new shell script properties (AGENT_HOOKS_LIBVIRT_VM_XML_TRANSFORMER_SHELL_SCRIPT,AGENT_HOOKS_LIBVIRT_VM_ON_START_SHELL_SCRIPT, etc.) for VM lifecycle hooks, enabling execution of shell scripts for VM state changes. [1] [2] [3]Resource management updates:
api/src/main/java/com/cloud/capacity/Capacity.java: Updated GPU capacity type ID from19to11.api/src/main/java/com/cloud/configuration/Resource.java: Added a new resource type for GPUs (gpu).api/src/main/java/com/cloud/user/ResourceLimitService.java: Introduced new configuration keys for GPU limits at the account, domain, and project levels (DefaultMaxAccountGpus,DefaultMaxDomainGpus, etc.). Added methods to check, increment, and decrement GPU resource limits. [1] [2]Miscellaneous updates:
.github/workflows/ci.yml: Added a new smoke test for deploying VMs with vGPU enabled (smoke/test_deploy_vgpu_enabled_vm).api/src/main/java/org/apache/cloudstack/api/ApiConstants.java: Added constants for GPU-related attributes such asBUS_ADDRESSandDEVICE_NAME. [1] [2]Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
This was tested locally on my laptop with passthrough of a consumer graphics card (NVIDIA RTX 3050). Due to unavailability of actual hardware, I wasn't able to test with vGPU profiles or mdev.
Framework level testing was done using the simulator plugin.
How did you try to break this feature and the system with this change?