Browse Source

Use QEMU ACPI shutdown to avoid bad exit code.

Giovanni Mascellani 4 years ago
parent
commit
5c704fe41d
2 changed files with 15 additions and 13 deletions
  1. 10 10
      .gitlab-ci.yml
  2. 5 3
      lib/shutdown.asm

+ 10 - 10
.gitlab-ci.yml

@@ -1,4 +1,4 @@
-image: debian:unstable
+image: giomasce/testenv
 
 variables:
   GIT_STRATEGY: clone
@@ -8,8 +8,8 @@ variables:
 before_script:
   - cat /proc/cpuinfo
   - cat /proc/meminfo
-  - apt-get update -qq
-  - apt-get install -y -qq eatmydata
+  - apt-get update
+  - apt-get install -y --no-upgrade eatmydata
 
 stages:
   - build
@@ -18,7 +18,7 @@ stages:
 build:
   stage: build
   script:
-    - eatmydata apt-get install -y -qq make nasm python3 qemu-utils
+    - eatmydata apt-get install -y --no-upgrade make nasm python3 qemu-utils
     - bash test/build_all_variants.sh
     - ls -l build/asmg.x86.exe build/asmg_dbg.x86.exe
   artifacts:
@@ -28,18 +28,18 @@ build:
 tests:
   stage: test
   script:
-    - eatmydata apt-get install -y -qq python3 qemu-system-x86
-    - "(echo -n | qemu-system-i386 -hda artifacts/tests/boot_asmg.x86.qcow2 -serial stdio -device isa-debug-exit -display none -m 256M -enable-kvm -cpu host || true) | ./test/decode_tests.py"
+    - eatmydata apt-get install -y --no-upgrade python3 qemu-system-x86
+    - "qemu-system-i386 -hda artifacts/tests/boot_asmg.x86.qcow2 -serial file:/dev/stdout -display none -m 256M -enable-kvm | ./test/decode_tests.py"
 
 mm0:
   stage: test
   script:
-    - eatmydata apt-get install -y -qq python3 qemu-system-x86
-    - "(echo -n | qemu-system-i386 -hda artifacts/mm0/boot_asmg.x86.qcow2 -serial stdio -device isa-debug-exit -display none -m 256M -enable-kvm -cpu host || true) | ./test/decode_tests.py just_malloc"
+    - eatmydata apt-get install -y --no-upgrade python3 qemu-system-x86
+    - "qemu-system-i386 -hda artifacts/mm0/boot_asmg.x86.qcow2 -serial file:/dev/stdout -display none -m 256M -enable-kvm | ./test/decode_tests.py just_malloc"
 
 tinycc:
   stage: test
   script:
-    - eatmydata apt-get install -y -qq python3 qemu-system-x86
+    - eatmydata apt-get install -y --no-upgrade python3 qemu-system-x86
     - cd http && python3 -m http.server 8080 &
-    - "(echo -n | qemu-system-i386 -hda artifacts/tinycc/boot_asmg.x86.qcow2 -serial stdio -device isa-debug-exit -display none -m 256M -enable-kvm -cpu host || true) | ./test/decode_tests.py just_malloc"
+    - "qemu-system-i386 -hda artifacts/tinycc/boot_asmg.x86.qcow2 -serial file:/dev/stdout -display none -m 256M -enable-kvm | ./test/decode_tests.py just_malloc"

+ 5 - 3
lib/shutdown.asm

@@ -17,10 +17,12 @@
 
   section .text
 
-  ;; Try to shutdown a qemu host invoked with "-device isa-debug-exit"
 qemu_shutdown:
-  mov edx, 0x501
-  out dx, al
+  ;; mov edx, 0x501                ; QEMU debug shutdown (requires "-device isa-debug-exit")
+  ;; out dx, al
+  mov edx, 0x604                ; QEMU ACPI shutdown (see https://wiki.osdev.org/Shutdown)
+  mov eax, 0x2000
+  out dx, ax
   ret
 
 shutdown: