feat(starry): add /dev/kmsg write-side device#1377
Merged
Conversation
This was referenced Jun 25, 2026
Open
Contributor
There was a problem hiding this comment.
PR #1377 审查总结:feat(starry): add /dev/kmsg write-side device
变更概述
本 PR 为 StarryOS 新增 /dev/kmsg 字符设备(char major 1, minor 11),用于在 journald 等用户态日志服务就绪前承接早期日志。实现写侧:每次 write() 作为一条记录,按 Linux devkmsg_write() 方式解析可选 <priority> 前缀,severity 取低 3 位,随后转发到 axlog 落到 console。读侧返回 EOF(Ok(0))。
代码分析
内核实现(kmsg.rs):
- 正确实现了
DeviceOpstrait,模式与Null、Zero等现有设备一致 parse()函数准确镜像 Linuxdevkmsg_write()的优先级解析逻辑:<开头 + 十进制数字 +>结尾才视为有效前缀- severity 到 axlog 级别的映射合理:0-3→error, 4→warn, 5-6→info, 7+→debug
DEFAULT_LEVEL=6(LOG_INFO) 与 Linuxdefault_message_loglevel行为一致- 使用
saturating_mul/saturating_add防止优先级数值溢出 strip_suffix(b"\n")避免 axlog 追加换行后输出空行NodeFlags::NON_CACHEABLE | NodeFlags::STREAM与 Null 等设备一致
设备注册(mod.rs):
DeviceId::new(1, 11)正确对应 Linux LANANA memory-device major 组mod kmsg无#[cfg]保护,与 null/zero/random 等基础设备保持一致- 注册位置合理,在
cpu_dma_latency之后、rtc0之前
测试覆盖
- 新增
test-suit/starryos/qemu-smp1/system/test-dev-kmsg/测试用例 - 测试覆盖:stat 节点身份(S_ISCHR + 1:11)、带前缀写入、无前缀写入、无换行写入、读侧 EOF 语义
- CMakeLists.txt 使用标准 install 到
usr/bin/starry-test-suit,被根 CMakeLists.txt 自动发现 - 测试代码结构清晰,错误处理完善
CI 状态
Check formatting— ✅ 通过Run sync-lint— ✅ 通过Test starry x86_64 qemu / run_container— ✅ 通过(包含 test-dev-kmsg)Test starry riscv64 qemu / run_container— ✅ 通过Test starry aarch64 qemu / run_container— ✅ 通过Test starry self-hosted board *— ✅ 全部通过- 工作流级别
failure结论来自 fork PR 矩阵中run_host/run_container互斥 job 被跳过,属预期行为
重复/重叠分析
origin/dev上无已有/dev/kmsg实现- 搜索 open PR:无与 kmsg 设备相关的 PR
- PR #1376 (USB xHCI)、PR #1370 (资源监控) 等 open PR 均与本 PR 无重叠
结论
实现正确,测试充分,CI 通过,无阻塞问题。批准合并。
Powered by mimo-v2.5-pro
ZR233
approved these changes
Jun 26, 2026
ZR233
left a comment
Member
There was a problem hiding this comment.
复查当前 head 487c42055dc04a3c56065b7258372a0125309d0f,未发现阻塞问题,批准合并。
检查结果:
- 变更实现
/dev/kmsg写侧字符设备,设备号1:11,每次write()作为一条记录,解析可选<priority>前缀后转发到 axlog;读侧按当前未实现 ring buffer 的约定返回 EOF。实现与现有 devfsDeviceOps风格一致。 - 新增
test-suit/starryos/qemu-smp1/system/test-dev-kmsg,布局符合 Starry grouped/system 子用例约定,安装到usr/bin/starry-test-suit。 - 当前 head 上无 unresolved review threads;base 分支没有已有
/dev/kmsg实现,open PR 搜索kmsg/devkmsg/DeviceId::new(1, 11)未发现重复实现。#1363 只是相邻修改dev/mod.rs的 inode builder,属于后续 rebase 风险,不是语义冲突。 - CI 覆盖:格式、sync-lint、clippy、std、x86_64/riscv64/aarch64 Starry QEMU、板测等多数 checks 已通过;日志确认新增用例在当前 head 的
qemu-smp1/system中被安装并运行通过,出现STARRY_SYSTEM_TEST_TIMING: elapsed_s=1 status=passed bin=/usr/bin/starry-test-suit/test-dev-kmsg。 - 本地隔离预审补充跑过
cargo fmt --check,通过;没有重复执行已由当前 head CI 覆盖的完整 Starry QEMU。
当前 CI 仍有一个 Test starry loongarch64 qemu / run_container 失败,但失败发生在后续既有 qemu-smp4/system LoongArch run,日志为 qemu-system-loongarch64: wrong value for queue_enable 0 和 virtio_address_space_lookup assertion;这不在本 PR 新增 /dev/kmsg/qemu-smp1/test-dev-kmsg 变更面内,已单独建 #1384 跟踪。
Merged
Antareske
pushed a commit
to Antareske/tgoskits
that referenced
this pull request
Jun 27, 2026
Antareske
pushed a commit
to Antareske/tgoskits
that referenced
this pull request
Jun 27, 2026
luodeb
pushed a commit
that referenced
this pull request
Jun 30, 2026
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.
新增 /dev/kmsg 字符设备(char major 1, minor 11),用于在 journald 等用户态
日志服务就绪前承接早期日志(如 systemd 以 log_target=kmsg 启动时的输出)。
前缀:紧跟数字后必须是 '>' 才视为前缀,severity 取低 3 位;
无前缀或格式非法时回退到默认 level,随后转发到 axlog 落到 console
带前缀/无前缀/无换行记录的完整写入、读侧 EOF 语义