<fix>[compute]: add allowed.tpm.vm.without.kms global config#3661
<fix>[compute]: add allowed.tpm.vm.without.kms global config#3661zstack-robot-1 wants to merge 1 commit intofeature-zsv-5.0.0-vm-support-vtpm-and-secucebootfrom
Conversation
Walkthrough新增布尔全局配置 Changes
Sequence Diagram(s)(无序列图) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java (1)
143-145: 缺少@BindResourceConfig注解——确认是否需要支持资源级别的配置覆盖对比同类 TPM 配置
RESET_TPM_AFTER_VM_CLONE(第 140 行),该配置具有@BindResourceConfig(value = {VmInstanceVO.class, ClusterVO.class}),允许按 VM 或集群级别覆盖全局配置。当前新增的
ALLOWED_TPM_VM_WITHOUT_KMS没有此注解,意味着只能在全局级别配置。如果这是有意设计(例如出于安全策略考虑,不应允许单个 VM 绕过 KMS 要求),则无需修改。否则可以考虑添加:`@BindResourceConfig`(value = {VmInstanceVO.class, ClusterVO.class})🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java` around lines 143 - 145, ALLOWED_TPM_VM_WITHOUT_KMS lacks the resource-binding annotation so it cannot be overridden per-VM or per-cluster like RESET_TPM_AFTER_VM_CLONE; if per-resource overrides are desired, add the `@BindResourceConfig` annotation (e.g. `@BindResourceConfig`(value = {VmInstanceVO.class, ClusterVO.class})) above the ALLOWED_TPM_VM_WITHOUT_KMS GlobalConfig declaration so it supports VM/Cluster-level configuration; if this is intentionally global-only, leave as-is and add a comment explaining the security rationale.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java`:
- Around line 143-145: ALLOWED_TPM_VM_WITHOUT_KMS lacks the resource-binding
annotation so it cannot be overridden per-VM or per-cluster like
RESET_TPM_AFTER_VM_CLONE; if per-resource overrides are desired, add the
`@BindResourceConfig` annotation (e.g. `@BindResourceConfig`(value =
{VmInstanceVO.class, ClusterVO.class})) above the ALLOWED_TPM_VM_WITHOUT_KMS
GlobalConfig declaration so it supports VM/Cluster-level configuration; if this
is intentionally global-only, leave as-is and add a comment explaining the
security rationale.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 047d107b-17d9-4615-9a5b-c82cc7184720
📒 Files selected for processing (2)
compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.javaplugin/kvm/src/main/java/org/zstack/kvm/tpm/KvmTpmExtensions.java
|
Comment from yaohua.wu: Review: MR !9521 — ZSV-11310变更概述:新增全局配置 正确性分析 ✅核心逻辑 正确且完整:
Warning
Suggestion
Verdict: APPROVED变更逻辑正确,skip 条件设计合理,下游 flow 联动无误。Warning 项建议确认 agent 端兼容性,但不阻塞合并。 🤖 Robot Reviewer |
Related: ZSV-11310 Change-Id: I67787561736968637666626a627366757775696a
22763e0 to
1d7126c
Compare
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 `@plugin/kvm/src/main/java/org/zstack/kvm/tpm/KvmTpmExtensions.java`:
- Around line 175-180: 当前的 shouldSkip 判定以任一为空(context.providerUuid 或
context.providerName)就跳过 create-dek,导致当 providerUuid 已存在但 providerName
临时为空时误放行;请将判定收敛为只有 context.providerUuid 为空才跳过(保留 providerName 不参与此 skip
决策),以便与启动前 run 的校验逻辑一致,修改 KvmTpmExtensions 中计算 shouldSkip 的逻辑(参见 shouldSkip 变量与
context.providerUuid / context.providerName)以只基于 providerUuid 为空决定返回 true。
🪄 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: 2647c130-dc97-48c7-8563-0fd1c9ac70e9
📒 Files selected for processing (2)
compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.javaplugin/kvm/src/main/java/org/zstack/kvm/tpm/KvmTpmExtensions.java
✅ Files skipped from review due to trivial changes (1)
- compute/src/main/java/org/zstack/compute/vm/VmGlobalConfig.java
| boolean shouldSkip = VmGlobalConfig.ALLOWED_TPM_VM_WITHOUT_KMS.value(Boolean.class) && | ||
| (StringUtils.isBlank(context.providerUuid) || StringUtils.isBlank(context.providerName)); | ||
| if (shouldSkip) { | ||
| logger.info("skip create-dek: allowed.tpm.vm.without.kms is enabled and no KMS provider bound"); | ||
| } | ||
| return shouldSkip; |
There was a problem hiding this comment.
skip 条件过宽,可能误把“已绑定 KMS”当成“无 KMS”放行。
Line 175 当前用 providerUuid/providerName 任一为空就跳过。这样在 providerUuid 已存在但 providerName 暂时为空时,会直接跳过 create-dek,导致 VM 在本应走 KMS 的情况下被放行为无 KMS 启动。
建议修复(收敛为“仅 providerUuid 缺失才跳过”,并与 run 前置校验保持一致)
@@
- boolean shouldSkip = VmGlobalConfig.ALLOWED_TPM_VM_WITHOUT_KMS.value(Boolean.class) &&
- (StringUtils.isBlank(context.providerUuid) || StringUtils.isBlank(context.providerName));
+ boolean shouldSkip = VmGlobalConfig.ALLOWED_TPM_VM_WITHOUT_KMS.value(Boolean.class) &&
+ StringUtils.isBlank(context.providerUuid);
if (shouldSkip) {
logger.info("skip create-dek: allowed.tpm.vm.without.kms is enabled and no KMS provider bound");
}
return shouldSkip;
@@
- if (StringUtils.isBlank(context.providerUuid) || StringUtils.isBlank(context.providerName)) {
+ if (StringUtils.isBlank(context.providerUuid)) {
trigger.fail(operr("missing TPM resource key binding for tpm[uuid:%s], attachKeyProviderToTpm must run before create-dek", context.tpmUuid));
return;
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugin/kvm/src/main/java/org/zstack/kvm/tpm/KvmTpmExtensions.java` around
lines 175 - 180, 当前的 shouldSkip 判定以任一为空(context.providerUuid 或
context.providerName)就跳过 create-dek,导致当 providerUuid 已存在但 providerName
临时为空时误放行;请将判定收敛为只有 context.providerUuid 为空才跳过(保留 providerName 不参与此 skip
决策),以便与启动前 run 的校验逻辑一致,修改 KvmTpmExtensions 中计算 shouldSkip 的逻辑(参见 shouldSkip 变量与
context.providerUuid / context.providerName)以只基于 providerUuid 为空决定返回 true。
Related: ZSV-11310
Change-Id: I67787561736968637666626a627366757775696a
sync from gitlab !9521