已合并
fix: 优化 QEMU rootfs 构建中 insmod_9p_vfs.sh 调用位置 #1760
xuhaijun创建于 24 天前
fix: 优化 QEMU rootfs 构建中 insmod_9p_vfs.sh 调用位置 #1760
已合并
共 1 个文件变更+15-14
| @@ -288,6 +288,13 @@ class QemuCi(object): | |||
| 288 | # 注释掉包含 rtos_snapshot.ko 的行 | 288 | # 注释掉包含 rtos_snapshot.ko 的行 |
| 289 | self.tool.run_command("sed -i '/rtos_snapshot.ko/s/^/#/g' {}".format(des), sudo=True) | 289 | self.tool.run_command("sed -i '/rtos_snapshot.ko/s/^/#/g' {}".format(des), sudo=True) |
| 290 | 290 | ||
| 291 | + # 检查 wait $PRE_DRV_PIDS 是否存在,不存在则报错 | ||
| 292 | + check_cmd = "grep -q 'wait \\$PRE_DRV_PIDS' {} || (echo 'ERROR: wait \\$PRE_DRV_PIDS not found' && exit 1)".format(des) | ||
| 293 | + self.tool.run_command(check_cmd, sudo=True) | ||
| 294 | + | ||
| 295 | + # 注释掉 wait $PRE_DRV_PIDS 行 | ||
| 296 | + self.tool.run_command("sed -i '/wait \\$PRE_DRV_PIDS/s/^/#/g' {}".format(des), sudo=True) | ||
| 297 | + | ||
| 291 | # 更精确地注释 cooling.sh 相关的代码块 | 298 | # 更精确地注释 cooling.sh 相关的代码块 |
| 292 | cooling_start_pattern = r'^[[:space:]]*if \[ -x /opt/bmc/script/cooling.sh \]; then' | 299 | cooling_start_pattern = r'^[[:space:]]*if \[ -x /opt/bmc/script/cooling.sh \]; then' |
| 293 | # 使用 sed 的范围匹配,从匹配 cooling.sh 的 if 行开始,到下一个 fi 行结束 | 300 | # 使用 sed 的范围匹配,从匹配 cooling.sh 的 if 行开始,到下一个 fi 行结束 |
| @@ -320,20 +327,14 @@ class QemuCi(object): | |||
| 320 | escaped_line = line.replace('/', '\\/').replace('&', '\\&') | 327 | escaped_line = line.replace('/', '\\/').replace('&', '\\&') |
| 321 | self.tool.run_command(f"sed -i '$a\\{escaped_line}' {des}", sudo=True) | 328 | self.tool.run_command(f"sed -i '$a\\{escaped_line}' {des}", sudo=True) |
| 322 | 329 | ||
| 323 | - # 在rc.sysinit文件末尾追加 9p.sh 的调用 | 330 | + # 检查 exec_main 调用行是否存在(绝对匹配,避免匹配 exec_main() {) |
| 324 | - # 将insmod_9p_vfs.sh放在rc.sysinit最后,确保所有环境准备完成后再执行 | 331 | + check_cmd = "grep -q '^exec_main$' {} || (echo 'ERROR: exec_main call not found' && exit 1)".format(des) |
| 325 | - # | 332 | + self.tool.run_command(check_cmd, sudo=True) |
| 326 | - # 问题背景:QEMU 启动后 eth0 网卡不存在 | 333 | + |
| 327 | - # 根本原因(来自 qemu_mockup PR #113 讨论): | 334 | + # 在 exec_main 调用前插入 insmod_9p_vfs.sh |
| 328 | - # - 设备树文件(hi1711_9p8c.dtb)缺少 GMAC 驱动所需的 memory_region 配置 | 335 | + # 使用 ^exec_main$ 确保绝对匹配,避免匹配 exec_main() { 函数定义 |
| 329 | - # - 导致 GMAC 驱动初始化失败,eth0 网卡无法正常工作 | 336 | + # 确保在主启动流程执行前先加载 9p vfs 模块 |
| 330 | - # - qemu_mockup 仓已通过修改 dtb 补充 memory_region 配置解决此问题 | 337 | + self.tool.run_command(f"sed -i '/^exec_main$/i\\sh /opt/bmc/insmod_9p_vfs.sh' {des}", sudo=True) |
| 331 | - # | ||
| 332 | - # 历史问题: | ||
| 333 | - # - 旧代码依赖 'rm -rf /var/lib' 作为 sed 插入点 | ||
| 334 | - # - 该代码行在 rc.sysinit 演进过程中被移除,导致插入失效 | ||
| 335 | - # - 改为追加到文件末尾,不依赖具体代码行,更加稳定可靠 | ||
| 336 | - self.tool.run_command(f"sed -i '$a sh /opt/bmc/insmod_9p_vfs.sh' {des}", sudo=True) | ||
| 337 | 338 | ||
| 338 | 339 | ||
| 339 | def __chown_rmcpd(self): | 340 | def __chown_rmcpd(self): |