Skip to content

ci(qemu): 统一 setup 流程并提升测试稳定性#363

Open
yoinspiration wants to merge 17 commits intoarceos-hypervisor:masterfrom
yoinspiration:dev/qemu-test-enhancement
Open

ci(qemu): 统一 setup 流程并提升测试稳定性#363
yoinspiration wants to merge 17 commits intoarceos-hypervisor:masterfrom
yoinspiration:dev/qemu-test-enhancement

Conversation

@yoinspiration
Copy link

@yoinspiration yoinspiration commented Feb 5, 2026

概述

本 PR 增强了 AxVisor 的 QEMU 测试流程,统一环境准备入口,并提升 CI 对 NimbOS 场景的稳定性与失败可观测性。

主要改动

1) 统一 QEMU 环境准备入口

  • 新增 scripts/setup_qemu.sh,统一支持 arceos / linux / nimbos
  • 自动完成镜像下载、VM 配置 patch、rootfs 准备
  • 移除冗余的旧 wrapper 脚本,减少重复逻辑与维护成本

2) NimbOS x86_64 配置与流程对齐

  • configs/vms/nimbos-x86_64-qemu-smp1.toml 对齐镜像下载目录
  • 使用 image_location = "memory",从宿主机镜像目录加载 kernel
  • CI 中自动下载并配置 axvm-bios.bin 以满足 NimbOS 引导要求

3) CI 失败检测增强

  • qemu-aarch64.toml 增加 fail_regex(如 panicked at),更早暴露 guest panic

4) NimbOS CI 自动输入与退出码修复

  • scripts/ci_run_qemu_nimbos.py 使用 PTY 启动子进程,确保输入可正确传递
  • 检测到 shell 提示后自动发送 usertests
  • 检测到 usertests passed! 后返回 0,避免“成功后主动终止 QEMU”导致 CI 误报失败

支持的测试组合

架构 Guest 系统 成功标志 特殊要求
aarch64 ArceOS Hello, world! -
aarch64 Linux test pass! -
x86_64 NimbOS usertests passed! Intel VT-x/KVM

测试结果

  • ✅ 本地验证 setup_qemu.sh 在 ArceOS / Linux / NimbOS 三类 Guest 的环境准备流程可执行
  • ✅ NimbOS CI 自动输入可触发 usertests
  • ✅ NimbOS 成功标志命中后退出码已修正,不再出现“测试通过但 Job 失败”误报
  • ✅ CI 配置更新已生效(含 fail_regex)

Out of Scope / Known Issues

  • ⚠️ PhytiumPi 实机曾出现 EXT4-fs error / No working init found,更偏向实验环境 SD 卡 / rootfs 镜像问题;当前未在本 PR 改动路径中复现,后续单独跟进。

检查清单

  • 本地测试通过(覆盖本 PR 改动路径)
  • 文档与脚本说明已更新
  • CI 配置已更新

@yoinspiration yoinspiration requested a review from ZR233 February 6, 2026 22:41
@yoinspiration yoinspiration force-pushed the dev/qemu-test-enhancement branch from 20756b2 to 37ae893 Compare February 6, 2026 22:49
@yoinspiration yoinspiration requested a review from ZR233 February 9, 2026 13:24
yoinspiration and others added 13 commits February 15, 2026 07:07
- switch x86_64 qemu to TCG with generic cpu
- adjust linux and nimbos VM kernel image paths for qemu tests
- refresh Cargo.lock after dependency updates
- 上游 https://github.com/YanQD/phytium-mci 仓库已删除 (Repository not found)
- 注释 modules/driver 中的 phytium-blk 功能及 phytium-mci 依赖
- 更新 configs/board/phytiumpi.toml 禁用 phytium-blk
- 从 Cargo.lock 移除 phytium-mci
- 添加 .cargo/config.toml 中 git-fetch-with-cli 配置

Phytium Pi 板卡构建暂不可用,QEMU aarch64 等场景可正常使用

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add setup_qemu_linux.sh: prepare Linux guest for aarch64 QEMU test
- Add setup_qemu_nimbos.sh: prepare NimbOS guest for x86_64 QEMU test
  - Inject kernel into rootfs for image_location=fs mode
  - Support mount/guestmount for rootfs modification
- Add qemu-x86_64-kvm.toml: KVM config for VT-x capable hosts
  - Use -accel kvm -cpu host for hardware virtualization

Co-authored-by: Cursor <cursoragent@cursor.com>
- 新增 setup_qemu.sh 统一入口,支持 --guest arceos|linux|nimbos
- 原 setup_qemu_*.sh 改为调用统一脚本的包装
- 简化多 Guest 环境准备流程

Co-authored-by: Cursor <cursoragent@cursor.com>
Align with uboot.toml, detect 'panicked at' as failure pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>
- 恢复 modules/driver 中 phytium-mci 依赖(使用 crates.io v0.1.1)
- 恢复 phytiumpi 板级配置中的 driver/phytium-blk
- 原 git 仓库已不可用,改为 crates.io 发布版本

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- point nimbos kernel_path to xtask image extract directory
- simplify setup_qemu.sh to stop injecting kernel into rootfs
- make nimbos config and setup script consistent with image_location=memory

Co-authored-by: Cursor <cursoragent@cursor.com>
NimbOS x86_64 requires axvm-bios at 0x8000 to bootstrap the guest.
Revert the incorrect removal in ab5d1d8 that assumed QEMU's default
BIOS would run inside the nested guest (it does not).

- Restore bios_path and bios_load_addr in nimbos-x86_64-qemu-smp1.toml
- Add axvm-bios.bin download in setup_qemu.sh for nimbos
- Add axvm-bios download in CI test-qemu workflow for x86_64 nimbos

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add scripts/ci_run_qemu_nimbos.py to automatically send 'usertests' command
  when 'Rust user shell' appears, so CI doesn't hang waiting for input
- Update test-qemu.yml to use the wrapper script only for NimbOS tests
- Other guests (ArceOS, Linux) continue to run directly without wrapper

Co-authored-by: Cursor <cursoragent@cursor.com>
@yoinspiration yoinspiration force-pushed the dev/qemu-test-enhancement branch from 3c598ee to 9b83866 Compare February 15, 2026 01:57
yoinspiration and others added 4 commits February 15, 2026 17:18
Replace subprocess.PIPE with pty so the child sees a real TTY. With PIPE
the child may treat stdin as non-interactive and not forward input to QEMU,
causing CI to hang waiting for 'usertests' input.

Also add fallback trigger '>>' in addition to 'Rust user shell'.

Co-authored-by: Cursor <cursoragent@cursor.com>
setup_qemu.sh already supports direct guest argument, making
the per-guest wrappers unnecessary.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add bilingual documentation covering environment setup, Rust toolchain
installation, KVM configuration, and running guest OSes on QEMU.

Co-authored-by: Cursor <cursoragent@cursor.com>
Return zero when `usertests passed!` is detected so CI doesn't fail when QEMU is intentionally terminated after success pattern matching.

Co-authored-by: Cursor <cursoragent@cursor.com>
@yoinspiration yoinspiration changed the title feat: QEMU 测试环境增强 - 统一 setup 脚本和 CI 改进 ci(qemu): 统一 setup 流程并提升测试稳定性 Feb 24, 2026
@yoinspiration
Copy link
Author

CI 在 cargo xtask image download qemu_aarch64_linux 步骤访问
https://raw.githubusercontent.com/arceos-hypervisor/axvisor-guest/refs/heads/main/registry/default.toml 超时,看起来是 CI runner 的网络问题,与本 PR 改动无关。
本地构建与相关测试已通过,麻烦维护者帮忙看下 CI 网络或考虑在 CI 中预置 /tmp/.axvisor-images。

fi

# NimbOS x86_64 requires axvm-bios for bootstrapping
if [[ "$GUEST" == "nimbos" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xtask download 已下载 nimbos axvm-bios.bin,此处重复操作?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants