Skip to content

fix(kvm): disable PMU on aarch64 for Kunpeng-920 panic#3650

Open
ZStack-Robot wants to merge 1 commit into5.5.12from
sync/zstackio/fix/5.5.12/ZSTAC-76375@@3
Open

fix(kvm): disable PMU on aarch64 for Kunpeng-920 panic#3650
ZStack-Robot wants to merge 1 commit into5.5.12from
sync/zstackio/fix/5.5.12/ZSTAC-76375@@3

Conversation

@ZStack-Robot
Copy link
Copy Markdown
Collaborator

On Kunpeng-920 V200 7270Z/5230Z, openEuler 24.03 guest kernel panics
during boot because __armv8pmu_probe_pmu reads PMMIR_EL1 (PMUv3.4
register) which the host KVM (Kylin 4.19) does not handle, causing
kvm_inject_undefined and guest kernel panic.

Add vm.pmu GlobalConfig (ResourceConfig, VM/Cluster level) defaulting
to false. On aarch64, read this config and set in
domain XML. Users can re-enable via ResourceConfig if needed.

Resolves: ZSTAC-76375
Change-Id: I6096bf5215fd4ff0b3170b9d299e38c6

sync from gitlab !9508

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent 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: 500928c9-33cb-48ed-ae82-b808bc6fa2e4

📥 Commits

Reviewing files that changed from the base of the PR and between 32bb5fa and 6f83070.

📒 Files selected for processing (4)
  • compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
  • test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmPmuConfigCase.groovy
✅ Files skipped from review due to trivial changes (1)
  • test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmPmuConfigCase.groovy
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java

Walkthrough

添加 VM_PMU 全局配置并绑定到 VM/Cluster;在 KVM StartVm 命令中新增 pmu 字段;在 KVM 主机启动逻辑中对 AArch64 架构读取并应用资源级 VM_PMU 配置;新增集成测试覆盖默认与资源级覆盖行为。(≤50 字)

Changes

Cohort / File(s) Summary
全局配置
compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java
新增导出全局配置 VM_PMU(key=vm.pmu),类型 Boolean,默认值 false,校验值限定为 "true","false",并通过 @BindResourceConfig 绑定到 VmInstanceVOClusterVO。注意资源级配置可覆盖。
KVM 命令
plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
StartVmCmd 中新增 @GrayVersion("5.5.12") private boolean pmu = true 字段及其 public getter/setter;该字段随启动命令序列化发送。
KVM 主机逻辑
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
startVm(...) 中针对 OSArchitecture.AARCH64 分支,读取 VmGlobalConfig.VM_PMU(通过 ResourceConfigFacade、按 VM UUID 作用域),并将值设置到 StartVmCmd.pmu
集成测试
test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmPmuConfigCase.groovy
新增集成测试 VmPmuConfigCase:校验全局配置存在与默认值,验证 x86 启动命令中 pmu 默认行为,以及验证按 VM 的 ResourceConfig 覆盖并持久化后重启时生效。

Sequence Diagram(s)

sequenceDiagram
    participant VM as 虚拟机/调用者
    participant GlobalCfg as 全局配置系统
    participant KVMHost as KVM 主机
    participant ResourceCfg as 资源配置门面
    participant KVMCmd as KVMAgent StartVmCmd

    VM->>GlobalCfg: 查询 vm.pmu 默认值
    GlobalCfg-->>VM: 返回默认 false

    KVMHost->>KVMHost: 检测目标主机架构
    alt 架构 == AArch64
        KVMHost->>ResourceCfg: 按 VM UUID 读取 vm.pmu 资源级配置
        ResourceCfg-->>KVMHost: 返回资源级值(若存在)
        KVMHost->>KVMCmd: 设置 StartVmCmd.pmu = 资源级值或全局默认
    else 其他架构(如 x86_64)
        KVMHost->>KVMCmd: 保持 StartVmCmd.pmu 的默认行为(true/null)
    end

    KVMHost->>KVMCmd: 发送启动命令(包含 pmu)
    KVMCmd-->>KVMHost: 命令已准备/响应
Loading

Estimated code review effort

🎯 3 (中等) | ⏱️ ~20 minutes

Poem

🐰 我是小兔检视者,轻啄代码花,
pmu 配置悄登场,架构间来回爬。
AArch64 听号令,资源级别说了算,
测试跑过验清楚,启动命令带花环。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 标题遵循了指定的[scope]: 格式,长度为54字符,符合72字符限制,并准确反映主要变更内容。
Description check ✅ Passed 描述与变更集相关,详细说明了问题背景、解决方案和相关配置的实现,包含JIRA票号和同步信息。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/zstackio/fix/5.5.12/ZSTAC-76375@@3

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.42.0)
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmPmuConfigCase.groovy`:
- Around line 138-140: The test only asserts PMU behavior for x86_64 (and null)
and misses an aarch64 branch; update VmPmuConfigCase.groovy to add an explicit
assertion for aarch64 by checking vm.architecture (e.g.,
"aarch64".equals(vm.architecture)) and assert startCmd.pmu == false with a clear
message like "aarch64 VM should have PMU disabled by default" next to the
existing x86_64/null check so the aarch64 regression is covered.
- Around line 180-182: The queryResourceConfig call that builds "conditions =
['name=${VmGlobalConfig.VM_PMU.name}', 'resourceUuid=${vm.uuid}']" is too broad
and may match same-named keys from other categories; update the conditions to
also include the correct category value (e.g., add
"category=${VmGlobalConfig.VM_PMU.category}" or the appropriate category string)
so the queryResourceConfig invocation filters by name, resourceUuid and category
for a precise assertion.
🪄 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: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: ea9fde7d-e3cf-45c5-8812-e507327bb723

📥 Commits

Reviewing files that changed from the base of the PR and between 1f6e0b3 and 32bb5fa.

📒 Files selected for processing (4)
  • compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
  • plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
  • test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmPmuConfigCase.groovy

On Kunpeng-920 V200 7270Z/5230Z, openEuler 24.03 guest kernel panics
during boot because __armv8pmu_probe_pmu reads PMMIR_EL1 (PMUv3.4
register) which the host KVM (Kylin 4.19) does not handle, causing
kvm_inject_undefined and guest kernel panic.

Add vm.pmu GlobalConfig (ResourceConfig, VM/Cluster level) defaulting
to false. On aarch64, read this config and set <pmu state='off'/> in
domain XML. Users can re-enable via ResourceConfig if needed.

Resolves: ZSTAC-76375
Change-Id: I6096bf5215fd4ff0b3170b9d299e38c6
@MatheMatrix MatheMatrix force-pushed the sync/zstackio/fix/5.5.12/ZSTAC-76375@@3 branch from 32bb5fa to 6f83070 Compare April 1, 2026 02:38
@MatheMatrix
Copy link
Copy Markdown
Owner

Comment from gitlab:

自上次添加REVIEWED标签(2026-03-31 17:55:58.000Z)后, 有新的COMMIT更新(2026-04-01 10:37:59.495Z), 所以移除了REVIEWED标签

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.

3 participants