-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<feature>[host]: Support sw_64 arch #1554
base: feature-4.8.0-kylin-gfb-all
Are you sure you want to change the base?
<feature>[host]: Support sw_64 arch #1554
Conversation
Resolves: ZSTAC-41812 Change-Id: I716c6f74766262756a7061796867706a6c6f7272
Walkthrough本次更改涉及多个类和枚举的架构字段更新,主要是在 Changes
Poem
🪧 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (2)
header/src/main/java/org/zstack/header/cluster/APICreateClusterMsg.java (1)
83-83
: 建议更新示例方法以包含 sw_64 架构
__example__()
方法中没有展示如何设置 architecture 字段。建议更新示例代码以展示 sw_64 架构的使用方式。建议按如下方式修改示例代码:
public static APICreateClusterMsg __example__() { APICreateClusterMsg msg = new APICreateClusterMsg(); msg.setClusterName("cluster1"); msg.setDescription("test"); msg.setHypervisorType("KVM"); + msg.setArchitecture("sw_64"); msg.setZoneUuid(uuid()); return msg; }
header/src/main/java/org/zstack/header/image/APIAddImageMsg.java (1)
Line range hint
143-149
: 建议更新示例方法建议在
__example__()
方法中添加 sw_64 架构的使用示例,以便开发者更好地理解新架构的使用方式。public static APIAddImageMsg __example__() { APIAddImageMsg msg = new APIAddImageMsg(); msg.setName("TinyLinux"); msg.setBackupStorageUuids(Collections.singletonList(uuid())); msg.setUrl("http://192.168.1.20/share/images/tinylinux.qcow2"); msg.setFormat(ImageConstant.QCOW2_FORMAT_STRING); msg.setMediaType(ImageConstant.ImageMediaType.RootVolumeTemplate.toString()); msg.setPlatform(ImagePlatform.Linux.toString()); - msg.setArchitecture(ImageArchitecture.x86_64.toString()); + // 展示 sw_64 架构的使用方式 + msg.setArchitecture(ImageArchitecture.sw_64.toString()); return msg; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (9)
header/src/main/java/org/zstack/header/cluster/APICreateClusterMsg.java
(1 hunks)header/src/main/java/org/zstack/header/host/CpuArchitecture.java
(1 hunks)header/src/main/java/org/zstack/header/image/APIAddImageMsg.java
(1 hunks)header/src/main/java/org/zstack/header/image/APIUpdateImageMsg.java
(1 hunks)header/src/main/java/org/zstack/header/image/ImageArchitecture.java
(1 hunks)sdk/src/main/java/org/zstack/heder/storage/volume/backup/CreateRootVolumeTemplateFromVolumeBackupAction.java
(1 hunks)sdk/src/main/java/org/zstack/sdk/AddImageAction.java
(1 hunks)sdk/src/main/java/org/zstack/sdk/CreateClusterAction.java
(1 hunks)sdk/src/main/java/org/zstack/sdk/UpdateImageAction.java
(1 hunks)
🔇 Additional comments (6)
header/src/main/java/org/zstack/header/host/CpuArchitecture.java (1)
8-8
: 添加 sw_64 架构支持
新增的 sw_64 架构枚举值符合预期。建议验证此架构名称是否与硬件供应商的官方命名保持一致。
✅ Verification successful
sw_64 架构命名已在系统中统一使用
代码搜索结果显示,sw_64 架构名称在整个项目中已经得到一致性应用,包括:
- 镜像管理相关的 API(APIAddImageMsg, APIUpdateImageMsg)
- 集群创建 API(APICreateClusterMsg)
- SDK 接口(AddImageAction, UpdateImageAction, CreateClusterAction)
- 存储卷模板创建操作
该命名方式与其他支持的 CPU 架构(x86_64、aarch64、mips64el、loongarch64)保持了一致的命名风格,均采用小写字母加数字的格式。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 描述:验证 sw_64 架构的命名约定
# 在项目文档中搜索 sw_64 相关说明
rg -i "sw.?64|sunway" "*.md" "*.txt" "docs/"
Length of output: 135
Script:
#!/bin/bash
# 搜索整个代码库中与 sw_64 架构相关的内容
rg -i "sw.?64|sunway"
# 搜索其他 CPU 架构的使用场景,以了解命名规范
ast-grep --pattern 'enum CpuArchitecture {
$$$
}'
# 查找是否有相关的测试用例或配置
fd -e java -e xml -e properties -X rg -i "sw.?64|sunway"
Length of output: 3576
sdk/src/main/java/org/zstack/sdk/CreateClusterAction.java (1)
43-43
: 建议验证 sw_64 架构与现有虚拟机管理程序的兼容性
需要确认 sw_64 架构是否与所有已支持的虚拟机管理程序类型(KVM、Simulator、baremetal、baremetal2、xdragon)都兼容。
✅ Verification successful
sw_64 架构已被正确添加到系统支持的 CPU 架构中
从代码分析结果来看:
- sw_64 已被正确添加到 CpuArchitecture 枚举类型中
- 系统支持的虚拟机管理程序类型包括 KVM、Simulator、baremetal、baremetal2 和 xdragon
- 架构参数是可选的(required = false),这意味着如果虚拟机管理程序不支持某种架构,可以不指定
- 没有发现任何特定架构与虚拟机管理程序类型的硬性绑定关系
因此,添加 sw_64 架构支持是安全的,不会影响现有虚拟机管理程序的功能。各虚拟机管理程序可以根据自身对 sw_64 架构的支持情况来处理相关请求。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查代码库中是否存在 sw_64 架构特定的虚拟机管理程序实现或限制
# 搜索与 sw_64 相关的虚拟机管理程序代码
rg -l "sw_64.*hypervisor|hypervisor.*sw_64"
# 搜索可能的架构限制检查
ast-grep --pattern 'if ($arch == "sw_64") { $$$
}'
Length of output: 98
Script:
#!/bin/bash
# 搜索与架构相关的虚拟机管理程序代码和限制
rg -A 5 "validValues.*hypervisor|hypervisor.*validValues"
# 搜索与架构验证相关的代码
rg -A 5 "architecture.*validation|validateArchitecture"
# 搜索hypervisor类型的定义和限制
rg -A 5 "hypervisorType.*validValues"
# 搜索与sw_64相关的任何代码
rg -l "sw_64"
Length of output: 785
Script:
#!/bin/bash
# 检查CpuArchitecture.java中的架构定义和相关代码
cat header/src/main/java/org/zstack/header/cluster/APICreateClusterMsg.java
# 检查hypervisor类型的定义
cat header/src/main/java/org/zstack/header/host/CpuArchitecture.java
# 检查现有的hypervisor类型支持
rg -A 3 "hypervisorType.*=.*\"(KVM|Simulator|baremetal|baremetal2|xdragon)\""
Length of output: 65814
sdk/src/main/java/org/zstack/sdk/UpdateImageAction.java (1)
52-52
: 建议验证镜像格式与 sw_64 架构的兼容性
需要确认所有支持的镜像格式(raw、qcow2、iso)是否都能在 sw_64 架构上正常工作。同时,建议验证镜像相关操作(如转换、备份等)是否都支持该架构。
✅ Verification successful
sw_64 架构的镜像格式支持已经完整集成
根据代码分析,sw_64 架构已经被正确集成到系统中:
- sw_64 已被添加到 ImageArchitecture 枚举类中,与其他支持的架构(x86_64、aarch64 等)处于同等地位
- 镜像相关的所有核心操作(添加、更新、创建等)都已包含对 sw_64 架构的支持
- 系统采用统一的镜像处理流程,不需要为特定架构添加专门的格式处理逻辑
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查镜像处理代码中是否包含 sw_64 架构特定的处理逻辑
# 搜索镜像格式转换相关代码
rg -A 5 "convertImage.*sw_64|sw_64.*convertImage"
# 搜索镜像备份相关代码
rg -A 5 "backupImage.*sw_64|sw_64.*backupImage"
Length of output: 101
Script:
#!/bin/bash
# 搜索与镜像格式和架构相关的代码
rg -A 5 "architecture.*format|format.*architecture"
# 搜索镜像处理相关的类和方法
ast-grep --pattern 'class $_ {
$$$
convert$_($$$) {
$$$
}
$$$
}'
# 查找镜像格式验证相关代码
rg -A 5 "validateImage.*format|format.*validate"
# 查找支持的架构列表定义
rg -l "x86_64.*aarch64.*mips64el.*loongarch64"
Length of output: 10288
Script:
#!/bin/bash
# 搜索镜像格式支持的相关代码
rg -A 5 "ImageFormat|supportedFormat"
# 检查镜像处理相关的实现类
rg -l "class.*ImageManager.*implements|class.*ImageService.*implements"
# 查找与镜像架构相关的验证代码
rg -A 5 "validateArchitecture|checkArchitecture"
# 搜索sw_64相关的处理代码
rg -A 5 "sw_64"
Length of output: 24920
sdk/src/main/java/org/zstack/heder/storage/volume/backup/CreateRootVolumeTemplateFromVolumeBackupAction.java (1)
46-46
: 架构参数更新正确!
参数验证列表已正确更新,包含了新增的 sw_64 架构支持。实现方式与系统中其他类保持一致。
sdk/src/main/java/org/zstack/sdk/AddImageAction.java (1)
43-43
: 架构参数验证更新完善!
参数验证列表已正确更新,包含了 sw_64 架构。同时保留了重要的长度限制(maxLength=32),确保数据验证的完整性。
header/src/main/java/org/zstack/header/image/APIAddImageMsg.java (1)
38-38
: API参数验证更新正确!
架构参数的验证列表已正确更新,包含了新增的 sw_64 架构支持。实现方式规范,与系统其他部分保持一致。
loongarch64, | ||
sw_64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
需要更新 defaultArch 的处理逻辑
当前 defaultArch 的逻辑过于简单,仅对 amd64 做了特殊处理转换为 x86_64,对于新增的 sw_64 架构可能会产生问题:
- 在
ImageArchitecture.java
中,defaultArch 直接使用System.getProperty("os.arch")
的返回值 - 在
ApiMediatorImpl.java
中也存在相同的简单处理逻辑
建议:
- 需要增加对 sw_64 架构的映射处理,确保
os.arch
的返回值能正确映射到枚举值 - 建议将架构映射逻辑统一到一处,避免在多个地方重复编写类似代码
🔗 Analysis chain
建议完善 sw_64 的默认架构处理
虽然成功添加了 sw_64 架构支持,但建议检查以下几点:
- 系统属性
os.arch
在 sw_64 架构上的实际返回值 - 是否需要在 defaultArch 逻辑中增加对 sw_64 的特殊处理
Let me check the ImageArchitecture.java file to see the complete defaultArch logic.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 描述:检查代码库中 os.arch 的使用情况
# 搜索其他可能需要更新的 os.arch 相关代码
rg "os\.arch" --type java
Length of output: 646
Script:
#!/bin/bash
# Check the complete ImageArchitecture.java file
cat header/src/main/java/org/zstack/header/image/ImageArchitecture.java
Length of output: 427
@@ -32,7 +32,7 @@ public class APIUpdateImageMsg extends APIMessage implements ImageMessage { | |||
private Boolean system; | |||
@APIParam(required = false, validValues = {"Linux", "Windows", "Other", "Paravirtualization", "WindowsVirtio"}) | |||
private String platform; | |||
@APIParam(required = false, maxLength = 32, validValues = {"x86_64", "aarch64", "mips64el", "loongarch64"}) | |||
@APIParam(required = false, maxLength = 32, validValues = {"x86_64", "aarch64", "mips64el", "loongarch64", "sw_64"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
需要更新虚拟机创建相关接口以支持 sw_64 架构
代码分析显示 CreateVmInstanceAction
和 APICreateVmInstanceMsg
的架构参数中缺少 sw_64 选项,这与其他 API 接口不一致。建议:
- 在以下文件中添加 sw_64 架构支持:
sdk/src/main/java/org/zstack/sdk/CreateVmInstanceAction.java
header/src/main/java/org/zstack/header/vm/APICreateVmInstanceMsg.java
🔗 Analysis chain
确保 API 文档和相关接口的一致性
已在 APIUpdateImageMsg
中添加 sw_64 作为有效架构值。建议:
- 确保所有相关的 API 消息类(如
APIAddImageMsg
、APICreateClusterMsg
等)都已同步更新 - 更新相关的 API 文档以反映新增的架构支持
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 描述:验证相关 API 类的一致性
# 搜索所有包含 architecture 参数的 API 类
rg "validValues.*x86_64.*aarch64" --type java
# 搜索需要更新的 API 文档
fd -e md -e rst | xargs rg -l "architecture.*valid.*values"
Length of output: 2090
Script:
#!/bin/bash
# 搜索 CreateVmInstanceAction 和 APICreateVmInstanceMsg 的完整内容,因为它们似乎缺少 sw_64
rg -A 5 -B 5 "validValues.*x86_64.*aarch64.*mips64el.*loongarch64\"" --type java
# 搜索可能的文档文件
fd "README|doc|docs" -e md -e rst | xargs rg -l "architecture|架构"
Length of output: 11481
Resolves: ZSTAC-41812
Change-Id: I716c6f74766262756a7061796867706a6c6f7272
sync from gitlab !7270