已合并
[Ubse] #feat# 支持获取当前部署环境, 若为仿真则不启用hcom主备倒换能力 #1496
[Ubse] #feat# 支持获取当前部署环境, 若为仿真则不启用hcom主备倒换能力 #1496
已合并
朱程成创建于 21 小时前
朱程成
朱程成
21 小时前

当前PR是否有AI参与:

[x] 否

[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :

参考:openEuler社区《生成式AI工具使用与开源贡献政策》

PR功能描述 / 为什么需要这个合入**:

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #

希望检视人员了解:

likedislike
Pull Request已成功合入, 合并人@openeuler-ci-bot
(感谢 朱程成 的贡献)
朱程成朱程成
21 小时前 创建了 pull request,commit 12a8232f
atomgit-bot
atomgit-bot
21 小时前 评论:

变更摘要

该 PR 为仿真(QEMU 虚拟机)环境提供部署环境识别能力:新增从 SMBIOS Type 1 结构解析系统制造商(Manufacturer)的接口 GetSystemManufacturer,并在通信引擎初始化时依据制造商是否为 QEMU 决定是否启用 hcom 主备倒换能力——仿真环境关闭该能力,物理机环境则开启。此前的 SMBIOS Type 1 解析仅返回"不支持"(UBSE_ERR_NOT_SUPPORTED),本 PR 将其落地为真实的字符串表解析实现。

主要改动

  • 新增制造商获取接口 GetSystemManufacturer:在 UbseSmbios 中新增 GetSystemManufacturer(std::string& manufacturer),通过 UbseSmbiosImpl 获取 SMBIOS Type 1 信息,若信息为空或制造商为空则返回 UBSE_ERROR,成功时返回 UBSE_OK,并在 ubse_smbios.h 中补充接口声明。

  • 实现 SMBIOS Type 1 的 Manufacturer 字段解析SmbiosStructureType1::FillSmbiosStructFromBuf 由原先直接返回 UBSE_ERR_NOT_SUPPORTED 改为真实解析——校验数据非空及长度足够后,读取偏移 0x04 处的字符串编号,通过 GetSmbiosString 从字符串表中取出厂商名,并将 LogSmbiosStructTypeInfo 的日志级别由 WARN 调整为 INFO 输出制造商信息。

  • manufacturer 字段类型改为 std::stringSmbiosStructureType1manufacturer 由定长 std::array<char, TYPE_1_MAX_LEN> 改为 std::string,以适配动态长度的字符串表解析结果。

  • 根据制造商动态配置 hcom 主备倒换UbseComEngine::InitEngineOptions 中原先固定 SetActiveBackup(false),现改为调用 GetSystemManufacturer 获取制造商,若获取失败或制造商为新增常量 QEMU_SYSTEM_MANUFACTURER(定义于 ubse_common_def.h,值为 "QEMU")则关闭主备倒换,否则开启。

  • 补充单元测试test_ubse_smbios.cpp 新增 MakeSystemInfo 构造辅助函数及多组用例,覆盖 Type 1 厂商字符串解码(含第二字符串、空字符串编号、缺失字符串、结构过短等异常场景)以及 GetSystemManufacturer 的成功/失败路径,并删除原先断言"不支持"的旧用例。

likedislike
atomgit-bot
atomgit-bot
21 小时前 评论:

代码审查

✅ 未发现问题

likedislike
openeuler-ci-botopeneuler-ci-bot成员
21 小时前 将hlinbo,shw030915,Gao_Victor,qmyyxtl,caowaterman设为审查人
openeuler-ci-botopeneuler-ci-bot成员
21 小时前 添加了label:sig/sig-UB-ServiceCore
此处折叠了88条消息 查看更多
xuchenfeng成员
17 小时前 评论:

/lgtm

likedislike
openeuler-ci-botopeneuler-ci-bot成员
17 小时前 添加了label:lgtm-xuchenfengcleancode
openeuler-ci-bot
openeuler-ci-bot成员
17 小时前 评论:

Review Code Feedback

  • The label lgtm-xuchenfengcleancode was added to this pull request. It means that xuchenfengcleancode reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
openeuler-ci-botopeneuler-ci-bot成员
17 小时前 关闭了关联的issue
openeuler-ci-botopeneuler-ci-bot成员
17 小时前 合入了pull request,合并节点 SHA:f68689ea952a0b59a2692e0079ca6c0ca8f0e52d