<fix>[compute]: delete vm device address if BIOS mode changed#367
<fix>[compute]: delete vm device address if BIOS mode changed#367MatheMatrix wants to merge 2 commits into5.0.0from
Conversation
Resolves: ZSTAC-59291 Change-Id: I7a756a626867657168616d677975717a61676f75 Signed-off-by: AlanJager <ye.zou@zstack.io> (cherry picked from commit babed02)
Resolves: ZSTAC-59291 Change-Id: I6c61726e656f6866776869746a777a7579676e69 Signed-off-by: AlanJager <ye.zou@zstack.io> (cherry picked from commit 9b546fd)
概述此次更新主要涉及对虚拟机启动模式设置的改进。在虚拟机基础类中增加了对启动模式变更的检测,并据此更新了标签的创建与删除。同时,在测试部分增加了对设置启动模式前后虚拟机设备地址记录存在性的验证。 变更
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (2)
- compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java (3 hunks)
- test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmBootModeCase.groovy (3 hunks)
Additional comments: 3
test/src/test/groovy/org/zstack/test/integration/kvm/vm/VmBootModeCase.groovy (2)
- 7-8: 导入语句的添加是为了支持新的测试用例,这些测试用例需要访问
VmInstanceDeviceAddressVO类。这是一个合理的更改。- 44-53: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [47-61]
在
testSetVmBootMode方法中添加的断言用于验证在BIOS模式更改前后VM设备地址的正确处理。这与PR目标一致,即确保在BIOS模式更改时,不再有效的VM设备地址被适当删除。这是一个重要的改进。建议在实际环境中对这些查询进行性能评估,以确保它们不会对系统性能产生负面影响。
compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java (1)
- 3681-3683: 此代码段在启动模式发生变化时正确地删除了所有设备地址,逻辑上没有问题。
| } | ||
|
|
||
| private void handle(APISetVmBootModeMsg msg) { | ||
| final boolean[] bootModeChanged = {false}; |
There was a problem hiding this comment.
使用长度为1的数组 bootModeChanged 来跟踪启动模式的变化可能不是最清晰的方法。考虑使用一个普通的布尔变量来替代,这样代码的可读性会更好。
| originLevel = msg.getBootMode(); | ||
| originLevel = bootMode; | ||
|
|
||
| if (bootMode != null && bootMode.equals(msg.getBootMode())) { |
There was a problem hiding this comment.
在比较字符串 bootMode 和 msg.getBootMode() 时,建议使用 equals 方法而不是 ==。这样可以确保比较的是字符串的内容而不是引用。
Resolves: ZSTAC-59291
Change-Id: I7a756a626867657168616d677975717a61676f75
Signed-off-by: AlanJager ye.zou@zstack.io
(cherry picked from commit babed02)
sync from gitlab !5912
Summary by CodeRabbit