feat: Add UEFI HTTP boot support#98
Open
Josen-B wants to merge 31 commits into
Open
Conversation
…action for UEFI loader
…network parameters
Collaborator
Author
…iagnostics for UEFI loader
Collaborator
Author
…ing to UEFI loader
There was a problem hiding this comment.
PR #98 Review: feat: Add UEFI HTTP Boot support
变更概览
本 PR 为 ostool 添加了 UEFI HTTP Boot 支持,涉及 45 个文件,新增约 9500 行代码。变更覆盖以下几个层次:
- 新增
httpbootcrate:no_std的 UEFI manifest 解析核心库,包含手工 JSON 解析器和 device path URI 提取 - UEFI 应用入口:通过
efi_main实现 UEFI HTTP 协议引导流程(manifest 下载 → kernel 下载 → ExitBootServices → 跳转入口) - loongarch64-uefi-loader:原生 C 加载器(TCP4/TLS/HTTP/manifest 支持)
- ostool-server 端:新增 HTTP Boot 文件服务、HTTPS 静态文件服务器、ProxyDHCP 服务
- ostool CLI 端:新增
run httpboot子命令,完整的上传→引导→会话管理流程
测例变更分析
本 PR 对现有测试行为的影响:
session_ws_lifecycle.rs:最小改动,仅添加了http_boot和proxy_dhcp配置字段到测试用的ServerConfig。这两个字段使用#[serde(default)],不影响已有的解析行为。config.rs测试:新增board_config_round_trip_supports_uefi_http_boot测试,验证新增的UefiHttpProfile序列化/反序列化。已有测试中新增了http_boot.root_dir相关断言,不影响已有行为。router.rs测试:新增http_boot_upload_manifest_and_public_download_use_board_current_path和http_boot_upload_rejects_non_uefi_http_board两个集成测试,验证 HTTP Boot 文件上传/下载流程。已有测试中BootConfigmatch 分支新增UefiHttp处理(panic),不影响已有逻辑。client.rs测试:新增parse_uefi_http_boot_profile测试。已有BootConfigmatch 分支新增UefiHttp处理。httpbootcrate:12 个单元测试全部通过(本地验证),覆盖 manifest 解析、地址解析、device path URI 提取、边界条件等。http_boot/files.rs:2 个单元测试,验证文件存储路径和路径校验。
结论:对现有行为没有破坏性影响。 所有改动都使用 #[serde(default)] 保证向后兼容,已有 match 分支仅补充了新的变体处理(panic),不改变已有分支行为。
代码质量评价
优点:
httpbootcrate 的no_stdJSON 解析器实现精简且健壮,错误处理清晰- UEFI ABI 绑定手工编写,结构体布局明确
- 文件上传使用原子 rename(先写临时文件再 rename),保证一致性
- 路径校验完善,防止目录遍历攻击
- HTTPS 静态文件服务器实现简洁,读取请求行和头部有长度限制
- ProxyDHCP 实现完整,包含 arch 匹配、MAC 过滤、IP 校验
建议改进(非阻塞):
httpboot/src/uefi/http.rs:283—poll_http_token使用 busy-wait 轮询(循环 10万次),建议添加注释说明 UEFI 环境下没有更好的等待机制httpboot/src/uefi/console.rs:10—write_console固定 192 元素 UTF-16 缓冲区,长消息会被静默截断,建议在截断时至少输出...提示ostool-server/src/api/router.rs:76— 短路径/B.EFI、/manifest.json、/kernel.bin使用硬编码 board_id"l",建议在文档中说明用途ostool-server/src/config.rs:74—HttpBootHttpsConfig默认证书路径,如用户启用 HTTPS 但未创建证书,错误信息较底层,建议增加友好提示ostool-server/src/api/router.rs:1190—put_http_boot_file中读取两次config,两次读取之间配置可能已变,建议复用
CI 状态
所有 CI 检查均已通过:check (stable, x86_64-unknown-linux-gnu) ✅、Release-plz PR ✅、build ✅、deploy ✅
总结
功能完整、测试覆盖良好、对现有行为无破坏性影响。CI 全绿,12 个 httpboot 单元测试本地验证全部通过。建议合并。
Powered by glm-5.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.