refactor(appium-tests): split the QEMU flags the action supplies itself

qemu-kvm-action always builds -cpu, -m, -smp and -enable-kvm from its own
inputs, so a flags list that also carries them produces a command line with
each specified twice, where which one wins depends on argument order.

Separates them into VM_ACCEL_FLAGS, which run-vm.sh passes and CI leaves to
the action's inputs, from VM_QEMU_FLAGS, which is the shared device list and
is safe for both. -machine stays in the shared list because the action has
no input for it.
This commit is contained in:
Davide Depau committed 2026-08-15 20:30:36 +02:00
1 parent d3d1174fff
commit 4b46223dc6
3 files changed
+38 -25

No files matched your search

+23 -20
View File
@@ -8,7 +8,7 @@ on:
workflow_dispatch:
env:
# BLISSOS_FILE, BLISSOS_URL, VM_CMDLINE and the QEMU flags all come from
# The guest image coordinates and QEMU flags all come from
# appium-tests/scripts/vm-config.sh, loaded by the "Load VM config" step below.
VM_DIR: /appium-vm
@@ -156,18 +156,22 @@ jobs:
- name: Load VM config
run: |
source appium-tests/scripts/vm-config.sh
vm_qemu_flags
{
echo "BLISSOS_FILE=$BLISSOS_FILE"
echo "BLISSOS_URL=$BLISSOS_URL"
echo "VM_KERNEL=$VM_KERNEL"
echo "VM_INITRD=$VM_INITRD"
echo "VM_CMDLINE=$VM_CMDLINE"
echo "LINEAGE_RELEASE=$LINEAGE_RELEASE"
echo "VM_GUEST_ARCH=$VM_GUEST_ARCH"
echo "VM_CPU=$VM_CPU"
echo "VM_SMP=$VM_SMP"
echo "VM_MEMORY=$VM_MEMORY"
echo "VM_ENABLE_KVM=$([ "$VM_ACCEL" = kvm ] && echo true || echo false)"
echo "VM_DISPLAY_GL=$VM_DISPLAY_GL"
# Only the device flags: -cpu/-smp/-m/-accel are passed as action inputs instead,
# since qemu-kvm-action builds those itself and duplicating them is ambiguous.
echo 'VM_QEMU_FLAGS<<VM_QEMU_FLAGS_EOF'
printf '%s\n' "${VM_QEMU_FLAGS[@]}"
echo 'VM_QEMU_FLAGS_EOF'
} >> "$GITHUB_ENV"
echo "Host GL available: $VM_GL"
echo "Guest: LineageOS $LINEAGE_RELEASE ($VM_GUEST_ARCH), accel $VM_ACCEL, GL $VM_GL"
- name: Download APK
uses: actions/download-artifact@v5
@@ -199,25 +203,22 @@ jobs:
sudo mkdir "$VM_DIR"
sudo chown "$USER" "$VM_DIR"
- name: Restore BlissOS image from cache
- name: Restore guest image from cache
uses: actions/cache/restore@v4
with:
key: ${{ env.BLISSOS_FILE }}
restore-keys: ${{ env.BLISSOS_FILE }}
key: lineage-${{ env.LINEAGE_RELEASE }}-${{ env.VM_GUEST_ARCH }}
restore-keys: lineage-${{ env.LINEAGE_RELEASE }}-${{ env.VM_GUEST_ARCH }}
path: ${{ env.VM_DIR }}
- name: Prepare BlissOS VM
- name: Prepare VM
id: prepare-vm
run: |
./appium-tests/scripts/prepare-vm.sh
# Save cache space by removing the ISO, we only need the extracted contents for QEMU
rm -f "${{ env.VM_DIR }}/${{ env.BLISSOS_FILE }}"
run: ./appium-tests/scripts/prepare-vm.sh
- name: Store BlissOS to cache
- name: Store guest image to cache
uses: actions/cache/save@v4
if: steps.prepare-vm.outputs.cached == 0
with:
key: ${{ env.BLISSOS_FILE }}
key: lineage-${{ env.LINEAGE_RELEASE }}-${{ env.VM_GUEST_ARCH }}
path: ${{ env.VM_DIR }}
- name: Create virtual USB drive image
@@ -228,10 +229,12 @@ jobs:
uses: etchdroid/qemu-kvm-action@v2
with:
video-record: true
kernel: ${{ env.VM_KERNEL }}
initrd: ${{ env.VM_INITRD }}
cmdline: ${{ env.VM_CMDLINE }}
video-output: vm-outputs/recording.mkv
# The guest boots from disk over UEFI, so there is no kernel/initrd/cmdline.
cpu: ${{ env.VM_CPU }}
smp: ${{ env.VM_SMP }}
memory: ${{ env.VM_MEMORY }}
enable-kvm: ${{ env.VM_ENABLE_KVM }}
flags: |
-chardev
stdio,id=char0,logfile=vm-outputs/serial.log,signal=off
+1
View File
@@ -128,6 +128,7 @@ echo
trap stop_viewer EXIT
"$VM_QEMU_BIN" \
"${VM_ACCEL_FLAGS[@]}" \
"${VM_QEMU_FLAGS[@]}" \
"${DISPLAY_ARGS[@]}" \
-serial "file:$SERIAL_LOG" &
+14 -5
View File
@@ -139,21 +139,30 @@ else
VM_DISPLAY_GL=''
fi
# QEMU flags shared by the local and CI invocations, one argument per array element.
# Deliberately excluded because the two differ on purpose: the display backend (see
# VM_DISPLAY_GL above) and the serial routing.
# QEMU flags, split into two arrays because CI and local invoke QEMU differently.
#
# VM_ACCEL_FLAGS holds exactly what qemu-kvm-action already builds from its own inputs
# (`-cpu`, `-m`, `-smp`, plus `-enable-kvm`), so CI must NOT pass these again -- it supplies
# them as action inputs instead, and duplicating them just makes the final command line
# ambiguous. run-vm.sh passes both arrays.
#
# Everything else is shared. Deliberately excluded from both because they genuinely differ:
# the display backend (see VM_DISPLAY_GL above) and the serial routing.
#
# Both USB controllers are intentional: xhci is USB 3 (fast path), uhci is USB 1.1 (slow path).
# The tests pick between them via QEMU_USB_BUS / QEMU_USB_SLOW_BUS, see
# appium-tests/etchdroid/config.py. Input devices share the xhci bus because machine `virt` has
# no default USB controller.
vm_qemu_flags() {
VM_QEMU_FLAGS=(
-machine "$VM_MACHINE"
VM_ACCEL_FLAGS=(
-accel "$VM_ACCEL"
-cpu "$VM_CPU"
-smp "$VM_SMP"
-m "$VM_MEMORY"
)
VM_QEMU_FLAGS=(
-machine "$VM_MACHINE"
-drive "if=pflash,unit=0,format=raw,readonly=on,file=$(vm_find_uefi_code)"
-drive "if=pflash,unit=1,format=$VM_IMAGE_FORMAT,file=$VM_EFI_VARS"
-drive "file=$VM_VDA,if=none,id=vda,format=$VM_IMAGE_FORMAT,discard=unmap,detect-zeroes=unmap"