Files
usbip/.github/workflows/qemu.yml
Jiajie Chen 411e63f8e8 Add QEMU end-to-end test verifying simulated USB devices
Boot a real Linux inside QEMU and confirm that simulated USB/IP devices
work against a real kernel (vhci-hcd + cdc_acm):

- Add examples/demo.rs: a single server exporting a HID keyboard and a
  CDC ACM serial device on port 3240.
- Add scripts/qemu/: build a minimal initramfs (host kernel + busybox +
  usbip tool + demo server), boot it in QEMU, attach the simulated devices
  over 127.0.0.1, and verify:
    * the serial port emits 'a' (0x61)  -> SERIAL_TEST
    * the keyboard generates a KEY_1 input event -> KEYBOARD_TEST
- Add .github/workflows/qemu.yml to run this in CI (KVM when available,
  TCG fallback otherwise), uploading the serial console log as an artefact.
2026-09-04 00:16:40 +08:00

55 lines
1.9 KiB
YAML

name: QEMU usbip integration test
# Boot a real Linux inside QEMU and verify that the *simulated* USB devices
# exported by this crate actually work (a CDC ACM serial port and a HID keyboard).
on: [push, pull_request]
jobs:
qemu-test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install system packages
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
qemu-system-x86 busybox-static cpio usb.ids
# The usbip userspace tool ships in the distro 'usbip' package (universe),
# or in linux-tools. Try both and make sure a binary is available.
if ! sudo apt-get install -y usbip; then
sudo apt-get install -y linux-tools-common linux-tools-generic
fi
echo "--- installed binaries ---"
ls -l /usr/bin/busybox /usr/bin/qemu-system-x86_64 2>/dev/null || true
ls -l /usr/sbin/usbip /usr/bin/usbip 2>/dev/null || true
- name: Preflight checks
run: |
set -euo pipefail
echo "kernel: $(uname -r)"
ls -l /boot/vmlinuz-$(uname -r)
ls -l /lib/modules/$(uname -r)/kernel/drivers/usb/usbip/ 2>/dev/null || true
ls -l /lib/modules/$(uname -r)/kernel/drivers/usb/class/cdc-acm.ko 2>/dev/null || true
command -v usbip >/dev/null 2>&1 || test -x /usr/sbin/usbip
test -e /dev/kvm && echo "KVM: available" || echo "KVM: not available (will use TCG)"
- name: Run QEMU end-to-end test
run: |
./scripts/qemu/run-qemu-test.sh --build --dump-log
- name: Upload serial console log
if: always()
uses: actions/upload-artifact@v4
with:
name: qemu-serial-log
path: .qemu-serial.log
if-no-files-found: ignore