Skip to content

<fix>[kvm]: disable arm vm pmu by default#4420

Open
zstack-robot-2 wants to merge 1 commit into
5.4.10from
sync/zstackio/fix/5.4.10/ZSTAC-86338@@3
Open

<fix>[kvm]: disable arm vm pmu by default#4420
zstack-robot-2 wants to merge 1 commit into
5.4.10from
sync/zstackio/fix/5.4.10/ZSTAC-86338@@3

Conversation

@zstack-robot-2

Copy link
Copy Markdown
Collaborator

Summary

Backport the PMU-off handling from ZSTAC-76375 to 5.4.10 for ZSTAC-86338.

Kunpeng-920 V200 7270Z/5230Z exposes PMUv3.4 PMMIR_EL1 to the guest. openEuler 24.03 / kernel 6.6 probes PMU during boot, while the reported Kylin 4.19 host KVM does not emulate the register, which can trigger a guest undefined-instruction panic and black console.

This MR:

  • adds vm.pmu, default false, with VM/Cluster resource binding
  • keeps StartVmCmd.pmu default true for compatibility
  • only on aarch64 destination hosts, reads vm.pmu and sends it to kvmagent
  • adds integration coverage for x86 compatibility, aarch64 default PMU-off, and resource override

Testing

  • git diff --cached --check passed before commit
  • RED check: confirmed origin/5.4.10 had no production PMU switch/XML references before this backport
  • Added VmPmuConfigCase

Local environment blockers:

  • mvn -f test/pom.xml -Dtest=org.zstack.test.integration.kvm.vm.VmPmuConfigCase test -DfailIfNoTests=false is blocked by missing local org.zstack:*:5.4.0 artifacts
  • mvn -DskipTests -pl compute,plugin/kvm -am compile is blocked before touched modules under local Java 17 by existing JAXB dependency in utils

sync from gitlab !10382

Backport PMU-off handling from ZSTAC-76375 to 5.4.10 for Kunpeng openEuler guest panic.

Resolves: ZSTAC-86338

Change-Id: I3c2dbe1944c300a803f50198b4c7ba575bd77dcc
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Could not fetch remote config from http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml: TimeoutError: The operation was aborted due to timeout
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3d55a078-406d-4f33-87da-4c310bbba763

📥 Commits

Reviewing files that changed from the base of the PR and between 08177ca and 7be6d61.

📒 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

Walkthrough

新增虚拟机 PMU(性能监控单元)配置支持:VmGlobalConfig 增加 VM_PMU 的默认值声明,KVMAgentCommands 的 StartVmCmd 新增 pmu 字段及存取方法,KVMHost 在 aarch64 架构下读取该配置并设置到启动命令中,并附带集成测试验证 x86/aarch64 默认行为与资源级覆盖。

Changes

VM PMU 配置

Layer / File(s) Summary
全局配置与启动命令字段定义
compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java, plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
VM_PMU 全局配置新增默认值 "false"、类型 Boolean 及说明;StartVmCmd 新增 pmu 字段(默认 true)及 isPmu/setPmu 方法。
KVMHost 中根据架构设置 PMU
plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
startVm 流程中针对 aarch64 架构读取 VM_PMU 资源配置并调用 cmd.setPmu 设置结果。
PMU 配置集成测试
test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmPmuConfigCase.groovy
新增测试用例验证全局配置默认值、x86 默认开启、aarch64 默认关闭以及资源级配置覆盖后重启生效的行为。

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant KVMHost
  participant VmGlobalConfig
  participant StartVmCmd
  participant KVMAgent

  KVMHost->>KVMHost: 判断镜像架构是否为 aarch64
  alt aarch64 架构
    KVMHost->>VmGlobalConfig: 读取 VM_PMU 资源配置(vmUuid)
    VmGlobalConfig-->>KVMHost: 返回 pmuEnabled
    KVMHost->>StartVmCmd: setPmu(pmuEnabled)
  end
  KVMHost->>StartVmCmd: 设置其他启动参数(setAcpi 等)
  KVMHost->>KVMAgent: 发送 StartVmCmd
Loading

Poem

小兔子敲代码到深夜,🐇
为鲲鹏芯片装上开关,
aarch64 静悄悄,PMU 默认关,
x86 依旧欢快转,
测试通过心欢喜,跳跳跳向前!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了本次变更的核心:默认禁用 ARM/aarch64 虚机 PMU。
Description check ✅ Passed 描述与变更一致,说明了 PMU 默认关闭、aarch64 透传、兼容性和测试覆盖。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.4.10/ZSTAC-86338@@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.44.0)
compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java

ast-grep exited with code unknown

plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java

ast-grep exited with code unknown

plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java

ast-grep exited with code unknown


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

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