ZSTAC-63024 Block cross-vendor VM migration#4199
Conversation
Keep migration compatibility in the existing KVM host allocator filter and derive known host CPU vendors from HostSystemTags.HOST_CPU_MODEL_NAME. Constraint: Hygon and Intel hosts are not live-migration compatible Rejected: Add a dedicated migration extension point | existing KVM migration property filtering already owns these checks Confidence: high Scope-risk: narrow Tested: PR docker ./runMavenProfile premium Tested: mvn test -Dtest=StabilityTestCase -Dcases=org.zstack.test.integration.kvm.host.MigrateVmCheckKvmPropertyCase -Dtimes=1 Resolves: ZSTAC-63024 Change-Id: I407c1a6358b2bfa91f5676cbbcab1fabd573603a
Recognize AMD, EPYC, AuthenticAMD and GenuineIntel host CPU model strings when filtering live migration candidates. Tested: mvn install -DskipTests -Djacoco.skip=true -DskipJacoco=true in plugin/kvm Tested: mvn test -Dtest=StabilityTestCase -Dcases=org.zstack.test.integration.kvm.host.MigrateVmCheckKvmPropertyCase -Dtimes=1 -Djacoco.skip=true -DskipJacoco=true in test Resolves: ZSTAC-63024 Change-Id: I4b4d9c703dc14942c63a24599e8299ed9a9b2afd
|
Warning
|
| 层级 / 文件 | 说明 |
|---|---|
属性定义与接口扩展 plugin/kvm/src/main/java/org/zstack/kvm/KVMHostAllocatorFilterExtensionPoint.java |
新增HOST_CPU_VENDOR属性常量、HostSystemTags导入,以及KVMPropertyChecker接口的propertyMatched默认方法,支持自定义属性匹配逻辑。 |
CPU供应商检查器实现与匹配逻辑更新 plugin/kvm/src/main/java/org/zstack/kvm/KVMHostAllocatorFilterExtensionPoint.java |
实现HostCpuVendorChecker从HOST_CPU_MODEL_NAME系统标签读取CPU型号名,按关键字映射为amd/hygon/intel供应商;将allPropertiesMatched的属性比对从Objects.equals改为调用各检查器的propertyMatched方法;更新过滤失败原因文案加入供应商不兼容描述。 |
测试用例验证CPU供应商兼容性 test/src/test/groovy/org/zstack/test/integration/kvm/host/MigrateVmCheckKvmPropertyCase.groovy |
新增Intel/AMD/Hygon型号常量、HostSystemTags导入,在环境模拟中设置宿主CPU型号,在testHostTokenMismatch后续场景中验证不同供应商组合下迁移候选主机的可用性。 |
预估评审工作量
🎯 3 (Moderate) | ⏱️ ~25 minutes
诗句
🐰 CPU厂商相逢必相同,
Intel、AMD、Hygon论芬芳,
迁移选主按此理,
主机兼容无差误,
测试场景尽周全!
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | PR title accurately summarizes the main change: blocking cross-vendor VM migration by implementing CPU vendor compatibility checks in KVM host allocator filter. |
| Description check | ✅ Passed | PR description is directly related to the changeset, providing clear summary of implementation approach, vendor recognition strategy, test coverage, and verification steps. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
sync/ye.zou/fix/ZSTAC-63024-5.5.28
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/src/test/groovy/org/zstack/test/integration/kvm/host/MigrateVmCheckKvmPropertyCase.groovy (1)
256-272: ⚡ Quick win建议:增加未知厂商(null vendor)的测试场景
当前测试覆盖了 Intel↔Hygon 和 Intel↔AMD 的不兼容场景,但未测试
toCpuVendor返回null的情况(即 CPU 型号无法识别时)。根据HostCpuVendorChecker.propertyMatched的实现,当任一方为null时应允许迁移。建议添加一个测试用例,验证当某主机的 CPU 型号无法识别为已知厂商时的迁移行为:
def unknownHostCpuModelName = "Unknown CPU Model XYZ" // 测试未知厂商应兼容任意厂商 HostSystemTags.HOST_CPU_MODEL_NAME.updateTagByToken(host2.uuid, HostSystemTags.HOST_CPU_MODEL_NAME_TOKEN, unknownHostCpuModelName) confirmMigrateAvailable(vm1) confirmMigrateAvailable(vm2)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/src/test/groovy/org/zstack/test/integration/kvm/host/MigrateVmCheckKvmPropertyCase.groovy` around lines 256 - 272, Add a test case that sets host2's CPU model to an unrecognized string and asserts migration is allowed: use HostSystemTags.HOST_CPU_MODEL_NAME.updateTagByToken(host2.uuid, HostSystemTags.HOST_CPU_MODEL_NAME_TOKEN, unknownHostCpuModelName) (define unknownHostCpuModelName = "Unknown CPU Model XYZ") and call confirmMigrateAvailable(vm1) and confirmMigrateAvailable(vm2); this verifies HostCpuVendorChecker.propertyMatched behavior when toCpuVendor returns null and complements the existing Intel/Hygon/AMD checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@plugin/kvm/src/main/java/org/zstack/kvm/KVMHostAllocatorFilterExtensionPoint.java`:
- Around line 24-25: The enum constant CPU_MODEL_NAME has a typo in its
associated string value; update the value in
KVMHostAllocatorFilterExtensionPoint (the CPU_MODEL_NAME enum entry) from "cpu
mode name" to "cpu model name" so the constant correctly reads
CPU_MODEL_NAME("cpu model name"); leave HOST_CPU_VENDOR unchanged.
---
Nitpick comments:
In
`@test/src/test/groovy/org/zstack/test/integration/kvm/host/MigrateVmCheckKvmPropertyCase.groovy`:
- Around line 256-272: Add a test case that sets host2's CPU model to an
unrecognized string and asserts migration is allowed: use
HostSystemTags.HOST_CPU_MODEL_NAME.updateTagByToken(host2.uuid,
HostSystemTags.HOST_CPU_MODEL_NAME_TOKEN, unknownHostCpuModelName) (define
unknownHostCpuModelName = "Unknown CPU Model XYZ") and call
confirmMigrateAvailable(vm1) and confirmMigrateAvailable(vm2); this verifies
HostCpuVendorChecker.propertyMatched behavior when toCpuVendor returns null and
complements the existing Intel/Hygon/AMD checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 757fa610-be67-4aac-aed8-dfdcdf0d2913
📒 Files selected for processing (2)
plugin/kvm/src/main/java/org/zstack/kvm/KVMHostAllocatorFilterExtensionPoint.javatest/src/test/groovy/org/zstack/test/integration/kvm/host/MigrateVmCheckKvmPropertyCase.groovy
| CPU_MODEL_NAME("cpu mode name"), | ||
| HOST_CPU_VENDOR("host cpu vendor"); |
There was a problem hiding this comment.
枚举常量 CPU_MODEL_NAME 存在拼写错误
"cpu mode name" 应为 "cpu model name",当前拼写 "mode" 是错误的。
🐛 建议修复
- CPU_MODEL_NAME("cpu mode name"),
+ CPU_MODEL_NAME("cpu model name"),
HOST_CPU_VENDOR("host cpu vendor");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| CPU_MODEL_NAME("cpu mode name"), | |
| HOST_CPU_VENDOR("host cpu vendor"); | |
| CPU_MODEL_NAME("cpu model name"), | |
| HOST_CPU_VENDOR("host cpu vendor"); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@plugin/kvm/src/main/java/org/zstack/kvm/KVMHostAllocatorFilterExtensionPoint.java`
around lines 24 - 25, The enum constant CPU_MODEL_NAME has a typo in its
associated string value; update the value in
KVMHostAllocatorFilterExtensionPoint (the CPU_MODEL_NAME enum entry) from "cpu
mode name" to "cpu model name" so the constant correctly reads
CPU_MODEL_NAME("cpu model name"); leave HOST_CPU_VENDOR unchanged.
Summary
HostSystemTags.HOST_CPU_MODEL_NAMEinstead of adding a migration-specific extension point.Hygon/C86,Intel/GenuineIntel, andAMD/EPYC/AuthenticAMDhost CPU model strings.MigrateVmCheckKvmPropertyCasefor Intel/Hygon and Intel/AMD migration candidates.Verification
./runMavenProfile premiumpassed before the follow-up zstack-only patch.mvn install -DskipTests -Djacoco.skip=true -DskipJacoco=trueinplugin/kvmpassed.mvn test -Dtest=StabilityTestCase -Dcases=org.zstack.test.integration.kvm.host.MigrateVmCheckKvmPropertyCase -Dtimes=1 -Djacoco.skip=true -DskipJacoco=trueintestpassed.Resolves: ZSTAC-63024
sync from gitlab !10156