Skip to content

Conversation

@yoinspiration
Copy link

@yoinspiration yoinspiration commented Feb 5, 2026

概述

本 PR 增强了 AxVisor 的 QEMU 测试环境,提供了统一的测试环境准备脚本,并改进了 CI 配置以更好地检测测试失败。

主要改动

1. 统一 QEMU 测试环境准备脚本

  • 新增 scripts/setup_qemu.sh:统一的入口脚本,支持所有 Guest 系统

    • 支持 arceoslinuxnimbos 三种 Guest
    • 自动下载镜像、修改 VM 配置、准备 rootfs
    • 提供清晰的错误提示和使用说明
  • 重构现有脚本setup_qemu_arceos.shsetup_qemu_linux.shsetup_qemu_nimbos.sh 改为调用统一脚本的包装,减少代码重复

2. NimbOS x86_64 支持与配置统一

  • 对齐镜像下载与 VM 配置

    • 使用 cargo xtask image download qemu_x86_64_nimbos 下载并解压镜像到 /tmp/.axvisor-images/qemu_x86_64_nimbos
    • configs/vms/nimbos-x86_64-qemu-smp1.toml 中的 kernel_path 统一指向上述目录下的 qemu-x86_64
    • image_location = "memory":直接从宿主机镜像目录将 kernel 加载到内存中
  • 简化 NimbOS rootfs 处理逻辑

    • 移除对 NimbOS 的 rootfs 内核注入流程(不再依赖 mount / guestmount 等特权操作)
    • 所有 guest 的 rootfs 统一拷贝到 tmp/rootfs.img,避免对 CI 环境额外要求

3. CI 配置改进

  • 添加 fail_regex:在 qemu-aarch64.toml 中添加 "panicked at" 作为失败模式
    • uboot.toml 保持一致
    • 及早发现 Guest 系统崩溃

支持的测试组合

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

使用方式

快速开始

# ArceOS
./scripts/setup_qemu.sh arceos

# Linux
./scripts/setup_qemu.sh linux

# NimbOS (需要 VT-x/KVM)
./scripts/setup_qemu.sh nimbos

执行测试

脚本会自动输出对应的 cargo xtask qemu 命令,例如:

cargo xtask qemu \
  --build-config configs/board/qemu-aarch64.toml \
  --qemu-config .github/workflows/qemu-aarch64.toml \
  --vmconfigs configs/vms/arceos-aarch64-qemu-smp1.toml

技术细节

统一脚本设计

  • 配置驱动:通过配置表统一管理不同 Guest 的参数
  • 错误处理:完善的错误检查和提示
  • 向后兼容:原有脚本仍可使用,内部调用统一脚本

NimbOS 特殊处理

  • 使用 image_location = "memory",直接从宿主机镜像目录加载 kernel,避免对 guest rootfs 做写入或挂载操作。
  • 通过统一的 setup_qemu.sh nimbos 流程,准备好 kernel 与 rootfs 后,使用 qemu-x86_64-kvm.toml 在具备 VT-x/KVM 的环境中运行。
  • NimbOS x86_64 需要 axvm-bios 在 0x8000 处完成引导;setup 脚本和 CI 会自动下载 axvm-bios.bin 并配置 bios_path。

测试

  • ✅ 本地验证了 ArceOS、Linux、NimbOS 三种 Guest 的 环境准备流程(镜像下载、vmconfig patch、rootfs 准备等)可以正常执行
  • ✅ NimbOS x86_64 已修复:恢复 axvm-bios 加载,Guest 可在本地正常启动并通过 usertests
  • ⚠️ PhytiumPi 实机测试中,板侧 Linux 内核因根文件系统 EXT4-fs error 导致 No working init found,怀疑是实验环境 SD 卡 / rootfs 镜像损坏,与本 PR 改动无直接关系
  • ✅ CI 配置已更新,支持 fail_regex 检测
  • ✅ 向后兼容,不影响现有工作流

检查清单

  • 代码已通过本地测试
  • 提交信息遵循约定格式
  • 文档已更新(如需要)
  • CI 配置已更新

@yoinspiration yoinspiration requested a review from ZR233 February 6, 2026 22:41
yoinspiration and others added 7 commits February 7, 2026 06:48
- 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 依赖和 phytium-blk feature
- 恢复 phytiumpi 板级配置中的 driver/phytium-blk
- 上游仓库 https://github.com/YanQD/phytium-mci 已恢复可用

Co-authored-by: Cursor <cursoragent@cursor.com>
@yoinspiration yoinspiration force-pushed the dev/qemu-test-enhancement branch from 20756b2 to 37ae893 Compare February 6, 2026 22:49
Co-authored-by: Cursor <cursoragent@cursor.com>
@yoinspiration yoinspiration requested a review from ZR233 February 9, 2026 13:24
yoinspiration and others added 5 commits February 9, 2026 21:41
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>
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