Skip to content

Commit 0c4baa5

Browse files
author
xinhao.huang
committed
<fix>[gpu]: fix virtualized GPU incorrectly showing as allocatable
When GPU is virtualized (VFIO MDEV or SR-IOV), its allocateStatus should be Unallocatable instead of Unallocated to prevent incorrect allocation. Changes: 1. Add Unallocatable status to GpuAllocateStatus enum (SDK sync) 2. Add database migration SQL to fix existing data DBImpact Resolves: ZSTAC-81457 Change-Id: I66851c798d9a4cf2f401d24a6fdb9179972a15418
1 parent 7392c70 commit 0c4baa5

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

conf/db/upgrade/V5.5.6__schema.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,13 @@ UPDATE ModelServiceInstanceVO msi
219219
INNER JOIN PodVO p ON msi.vmInstanceUuid = p.uuid
220220
SET msi.clusterId = p.clusterId
221221
WHERE msi.clusterId IS NULL AND p.clusterId IS NOT NULL;
222+
223+
-- Fix GPU allocateStatus for virtualized devices
224+
-- Issue: Virtualized physical GPUs (with vGPUs generated) should show as Unallocatable, not Unallocated
225+
-- This UPDATE is idempotent: WHERE clause ensures only incorrect statuses are updated
226+
UPDATE `zstack`.`GpuDeviceVO` g
227+
INNER JOIN `zstack`.`PciDeviceVO` p ON g.`uuid` = p.`uuid`
228+
SET g.`allocateStatus` = 'Unallocatable'
229+
WHERE p.`virtStatus` IN ('VFIO_MDEV_VIRTUALIZED', 'SRIOV_VIRTUALIZED')
230+
AND p.`vmInstanceUuid` IS NULL
231+
AND g.`allocateStatus` != 'Unallocatable';

sdk/src/main/java/org/zstack/sdk/GpuAllocateStatus.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
public enum GpuAllocateStatus {
44
Unallocated,
55
Allocated,
6+
Unallocatable,
67
}

0 commit comments

Comments
 (0)