<fix>[pci]: split virt mode from capability lifecycle#3568
<fix>[pci]: split virt mode from capability lifecycle#3568MatheMatrix wants to merge 1 commit intofeature-5.5.12-dgpufrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough新增 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 分钟 Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 76-83: The UPDATE on table PciDeviceVO sets virtMode based solely
on virtStatus and will overwrite already-migrated virtMode to NULL on re-run;
modify the migration to be idempotent by restricting updates to rows that still
have old virtStatus values or where virtMode IS NULL (e.g., only update when
virtMode IS NULL AND virtStatus IN (old enums) or virtStatus IN (old enums)
regardless), and also guard the script with information_schema checks for the
existence of the PciDeviceVO table/columns and any constraints referenced so the
migration safely no-ops if schema has already been changed; locate references to
PciDeviceVO, virtMode, and virtStatus in the diff to apply these conditional
guards.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
Run ID: 010aec45-92fa-4666-a68c-b779e39be1ce
⛔ Files ignored due to path filters (4)
sdk/src/main/java/SourceClassMap.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/PciDeviceInventory.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/PciDeviceVirtMode.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/PciDeviceVirtStatus.javais excluded by!sdk/**
📒 Files selected for processing (1)
conf/db/upgrade/V5.5.12__schema.sql
1741ac0 to
3dd5ebd
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
conf/db/upgrade/V5.5.12__schema.sql (1)
89-99: 可选:合并virtMode的重复分支以降低维护成本
SRIOV的两个分支可合并,语义不变但更易读。♻️ 可选精简改法
UPDATE `zstack`.`PciDeviceVO` SET `virtMode` = CASE - WHEN `virtStatus` IN ('SRIOV_VIRTUALIZED') THEN 'SRIOV' - WHEN `virtStatus` = 'SRIOV_VIRTUAL' THEN 'SRIOV' + WHEN `virtStatus` IN ('SRIOV_VIRTUALIZED', 'SRIOV_VIRTUAL') THEN 'SRIOV' WHEN `virtStatus` IN ('VFIO_MDEV_VIRTUALIZED', 'VIRTUALIZED_BYPASS_ZSTACK') THEN 'VFIO_MDEV' WHEN `virtStatus` = 'TENSORFUSION_VIRTUALIZED' THEN 'TENSORFUSION' WHEN `virtStatus` = 'HAMI_VIRTUALIZED' THEN 'HAMI' ELSE NULL END WHERE `virtMode` IS NULL;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@conf/db/upgrade/V5.5.12__schema.sql` around lines 89 - 99, The UPDATE on table PciDeviceVO sets virtMode based on virtStatus and currently has two separate WHEN branches for SRIOV; simplify by merging those two SRIOV branches into a single WHEN clause (e.g., WHEN `virtStatus` IN ('SRIOV_VIRTUALIZED','SRIOV_VIRTUAL') THEN 'SRIOV') in the CASE expression that assigns `virtMode` (the UPDATE ... SET `virtMode` ... WHERE `virtMode` IS NULL block) to reduce duplication and improve readability.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@conf/db/upgrade/V5.5.12__schema.sql`:
- Around line 89-99: The UPDATE on table PciDeviceVO sets virtMode based on
virtStatus and currently has two separate WHEN branches for SRIOV; simplify by
merging those two SRIOV branches into a single WHEN clause (e.g., WHEN
`virtStatus` IN ('SRIOV_VIRTUALIZED','SRIOV_VIRTUAL') THEN 'SRIOV') in the CASE
expression that assigns `virtMode` (the UPDATE ... SET `virtMode` ... WHERE
`virtMode` IS NULL block) to reduce duplication and improve readability.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
Run ID: 75f5bb8b-66c6-4f31-9e49-ec38c414f029
⛔ Files ignored due to path filters (3)
sdk/src/main/java/org/zstack/sdk/PciDeviceInventory.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/PciDeviceVirtMode.javais excluded by!sdk/**sdk/src/main/java/org/zstack/sdk/PciDeviceVirtState.javais excluded by!sdk/**
📒 Files selected for processing (1)
conf/db/upgrade/V5.5.12__schema.sql
676bf36 to
1cc34b2
Compare
…scheduling DBImpact Introduce pci virtualization metadata with virtState, virtMode and persisted virtCapabilities. Backfill existing data in V5.5.12 and expose the new fields through SDK inventories. Normalize capability/mode derivation during PCI sync, keep upgrade retry idempotent, and avoid stale or inconsistent virtMode capability states. Use the new metadata in dGPU capability filtering/allocation flows and add coverage for PCI sync and dGPU cases. Resolves: ZSTAC-83477 Change-Id: I71736e666272737978676a74656d767a6a786c72
1cc34b2 to
1a54a97
Compare
Add virt mode and capability persistence to the PCI
virtualization schema upgrade for the new lifecycle
model.
Resolves: ZSTAC-83477
Change-Id: I834770000000000000000000000000000000003
sync from gitlab !9426