9797import com .cloud .exception .InvalidParameterValueException ;
9898import com .cloud .exception .PermissionDeniedException ;
9999import com .cloud .exception .ResourceInUseException ;
100- import com .cloud .gpu .GPU .vGPUType ;
101100import com .cloud .gpu .HostGpuGroupsVO ;
102101import com .cloud .gpu .VGPUTypesVO ;
103102import com .cloud .gpu .dao .HostGpuGroupsDao ;
@@ -1349,6 +1348,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
13491348
13501349 _gpuAvailability = _hostGpuGroupsDao .createSearchBuilder ();
13511350 _gpuAvailability .and ("hostId" , _gpuAvailability .entity ().getHostId (), Op .EQ );
1351+ _gpuAvailability .and ("groupName" , _gpuAvailability .entity ().getGroupName (), Op .EQ );
13521352 SearchBuilder <VGPUTypesVO > join1 = _vgpuTypesDao .createSearchBuilder ();
13531353 join1 .and ("vgpuType" , join1 .entity ().getVgpuType (), Op .EQ );
13541354 join1 .and ("remainingCapacity" , join1 .entity ().getRemainingCapacity (), Op .GT );
@@ -2508,21 +2508,19 @@ public boolean isHostGpuEnabled(long hostId) {
25082508 }
25092509
25102510 @ Override
2511- public List <HostGpuGroupsVO > listAvailableGPUDevice (long hostId , String vgpuType ) {
2512- if (vgpuType == null ) {
2513- vgpuType = vGPUType .passthrough .getType ();
2514- }
2511+ public List <HostGpuGroupsVO > listAvailableGPUDevice (long hostId , String groupName , String vgpuType ) {
25152512 Filter searchFilter = new Filter (VGPUTypesVO .class , "remainingCapacity" , false , null , null );
25162513 SearchCriteria <HostGpuGroupsVO > sc = _gpuAvailability .create ();
25172514 sc .setParameters ("hostId" , hostId );
2515+ sc .setParameters ("groupName" , groupName );
25182516 sc .setJoinParameters ("groupId" , "vgpuType" , vgpuType );
25192517 sc .setJoinParameters ("groupId" , "remainingCapacity" , 0 );
25202518 return _hostGpuGroupsDao .customSearch (sc , searchFilter );
25212519 }
25222520
25232521 @ Override
2524- public boolean isGPUDeviceAvailable (long hostId , String vgpuType ) {
2525- if (!listAvailableGPUDevice (hostId , vgpuType ).isEmpty ()) {
2522+ public boolean isGPUDeviceAvailable (long hostId , String groupName , String vgpuType ) {
2523+ if (!listAvailableGPUDevice (hostId , groupName , vgpuType ).isEmpty ()) {
25262524 return true ;
25272525 } else {
25282526 if (s_logger .isDebugEnabled ()) {
@@ -2533,8 +2531,8 @@ public boolean isGPUDeviceAvailable(long hostId, String vgpuType) {
25332531 }
25342532
25352533 @ Override
2536- public GPUDeviceTO getGPUDevice (long hostId , String vgpuType ) {
2537- HostGpuGroupsVO gpuDevice = listAvailableGPUDevice (hostId , vgpuType ).get (0 );
2534+ public GPUDeviceTO getGPUDevice (long hostId , String groupName , String vgpuType ) {
2535+ HostGpuGroupsVO gpuDevice = listAvailableGPUDevice (hostId , groupName , vgpuType ).get (0 );
25382536 return new GPUDeviceTO (gpuDevice .getGroupName (), vgpuType , null );
25392537 }
25402538
0 commit comments