Skip to content

<fix>[kvm]: fix Hygon_Customized CPU mode migration failure#3338

Open
ZStack-Robot wants to merge 2 commits into5.5.6from
sync/ye.zou/fix/ZSTAC-73095
Open

<fix>[kvm]: fix Hygon_Customized CPU mode migration failure#3338
ZStack-Robot wants to merge 2 commits into5.5.6from
sync/ye.zou/fix/ZSTAC-73095

Conversation

@ZStack-Robot
Copy link
Collaborator

Summary

  • Issue: ZSTAC-73095 - Hygon cluster with custom CPU mode Hygon_Customized fails live migration with CPU feature mismatch
  • Root Cause: KVMHost.java:4472 did not recognize CPU_MODE_HYGON_CUSTOMIZED as a special passthrough mode, treating it as a custom CPU model name. This caused invalid libvirt XML <cpu mode="custom"><model>Hygon_Customized</model></cpu>, which is not a valid libvirt CPU model.
  • Fix: Added CPU_MODE_HYGON_CUSTOMIZED to the condition check and convert it to host-passthrough when building StartVmCmd. Aligns with existing conversion logic in VmCpuVendorKvmStartVmExtension.java:65-89.

Changes

  • plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java: Added Hygon_Customized to host-passthrough conversion check (3 lines changed)

Test Plan

  • Requires Hygon hardware environment for full validation
  • Verify VM with Hygon_Customized CPU mode can live migrate between Hygon hosts
  • Verify non-Hygon CPU modes are unaffected
  • Fix follows same pattern as VmCpuVendorKvmStartVmExtension.java

Resolves: ZSTAC-73095

sync from gitlab !9167

When VM CPU mode is set to Hygon_Customized and live migration is performed, the migration fails because Hygon_Customized was being treated as a custom CPU model name rather than being converted to host-passthrough mode.

This fix adds CPU_MODE_HYGON_CUSTOMIZED to the condition check and converts it to host-passthrough during VM start, preventing CPU feature mismatch errors during migration on Hygon CPU clusters.

Resolves: ZSTAC-73095

Change-Id: Ic418091f1c466624ae7f9ee0b0f466092dde1b54
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

概览

本次提交扩展了KVM主机的虚拟机启动CPU模式处理逻辑,增加了对HYGON_CUSTOMIZED CPU模式的支持,并将其映射为HOST_PASSTHROUGH用于嵌套虚拟化配置。

变更列表

文件/内容组 变更摘要
CPU模式处理逻辑更新
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
添加HYGON_CUSTOMIZED CPU模式识别与处理,当vmCpuMode为HYGON_CUSTOMIZED时映射至HOST_PASSTHROUGH以支持嵌套虚拟化;其他模式行为保持不变。

代码审查工作量

🎯 2 (简单) | ⏱️ ~8 分钟

诗歌

🐰✨ 小兔来为你欢呼
Hygon芯片新添支持
CPU模式巧妙映射
嵌套虚拟更加顺畅
寥寥数行,大功告成!

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (4 files):

⚔️ build/pom.xml (content)
⚔️ core/pom.xml (content)
⚔️ network/src/main/java/org/zstack/network/service/DhcpExtension.java (content)
⚔️ plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java (content)

These conflicts must be resolved before merging into 5.5.6.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 标题完整遵循 [scope]: 格式(59字符),准确总结了Hygon自定义CPU模式迁移失败的主要修复内容。
Description check ✅ Passed 描述详细阐述了问题背景、根本原因和修复方案,与代码变更内容完全相关且信息充分。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/ye.zou/fix/ZSTAC-73095
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch sync/ye.zou/fix/ZSTAC-73095
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.40.5)
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

概览

在 KVMHost.startVm 方法中扩展了嵌套虚拟化处理逻辑,现支持 CPU_MODE_HYGON_CUSTOMIZED 模式。当模式为 HYGON_CUSTOMIZED 时,将其映射至 HOST_PASSTHROUGH,以避免 CPU 型号不匹配。其余分支保持不变。

变更

组织 / 文件 摘要
嵌套虚拟化模式处理
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
扩展 startVm 方法中的嵌套虚拟化条件判断,添加对 HYGON_CUSTOMIZED CPU 模式的支持,在该模式下将其转换为 HOST_PASSTHROUGH。

代码审查工作量评估

🎯 2 (简单) | ⏱️ ~12 分钟

🐰 兔子的欢呼~
芯片又添新模式,
HYGON 自定义来相助,
虚拟机启动更顺畅,
CPU 不再有冲突!
小小改动大作用 ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR title follows the required [scope]: format with 59 characters, well under the 72-character limit, and clearly describes the fix for Hygon_Customized CPU mode migration failure.
Description check ✅ Passed PR description is directly related to the changeset, providing detailed context about the issue, root cause, fix, and test plan for the Hygon_Customized CPU mode migration fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/ye.zou/fix/ZSTAC-73095

No actionable comments were generated in the recent review. 🎉

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.40.5)
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java

Comment @coderabbitai help to get the list of available commands and usage tips.

Resolves: ZSTAC-73095

Change-Id: I6c2209ddfc8febd8f5644c031b96428b646bd692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants