Skip to contentSkip to conversation

hw/vmapple: Allow running QTest framework on macOS

RFC In review Philippe Mathieu-Daudé 2 participants 3 messages Apr 1, 2025 – Apr 3, 2025

lore
Share & tools
lore
#0 lore raw

RFC 1/1 hw/vmapple: Allow running QTest framework on macOS

First, the VMapple machine only works with the ARM 'host' CPU type, which isn't accepted for QTest:

  $ qemu-system-aarch64 -M vmapple -accel qtest
  qemu-system-aarch64: The 'host' CPU type can only be used with KVM or HVF

Second, the QTest framework expects machines to be createable without specifying optional arguments, however the VMapple machine requires few of them:

  $ qemu-system-aarch64 -M vmapple -accel qtest
  qemu-system-aarch64: No firmware specified
  $ qemu-system-aarch64 -M vmapple -accel qtest -bios /dev/null
  qemu-system-aarch64: No AUX device. Please specify one as pflash drive.

Restrict some code path to QTest so we can at least run check-qtest, otherwise we get:

  $ make check-qtest-aarch64
  qemu-system-aarch64: The 'host' CPU type can only be used with KVM or HVF
  Broken pipe
  ../tests/qtest/libqtest.c:199: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
  ...
   7/26 qemu:qtest+qtest-aarch64 / qtest-aarch64/test-hmp     ERROR      24.71s   killed by signal 6 SIGABRT
   2/26 qemu:qtest+qtest-aarch64 / qtest-aarch64/qom-test     ERROR      71.23s   killed by signal 6 SIGABRT
---
 hw/vmapple/vmapple.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
hw/vmapple/vmapple.c +10 -3
index fa117bf1511..e16c0c72fe5 100644
@@ -48,6 +48,7 @@
 #include "qobject/qlist.h"
 #include "standard-headers/linux/input.h"
 #include "system/hvf.h"
+#include "system/qtest.h"
 #include "system/reset.h"
 #include "system/runstate.h"
 #include "system/system.h"
@@ -494,7 +495,9 @@ static void mach_vmapple_init(MachineState *machine)
                                 machine->ram);
 
     create_gic(vms, sysmem);
-    create_bdif(vms, sysmem);
+    if (!qtest_enabled()) {
+        create_bdif(vms, sysmem);
+    }
     create_pvpanic(vms, sysmem);
     create_aes(vms, sysmem);
     create_gfx(vms, sysmem);
@@ -504,7 +507,9 @@ static void mach_vmapple_init(MachineState *machine)
 
     create_gpio_devices(vms, VMAPPLE_GPIO, sysmem);
 
-    vmapple_firmware_init(vms, sysmem);
+    if (!qtest_enabled()) {
+        vmapple_firmware_init(vms, sysmem);
+    }
     create_cfg(vms, sysmem, &error_fatal);
 
     /* connect powerdown request */
@@ -541,17 +546,19 @@ static const CPUArchIdList *vmapple_possible_cpu_arch_ids(MachineState *ms)
 {
     int n;
     unsigned int max_cpus = ms->smp.max_cpus;
+    const char *cpu_type;
 
     if (ms->possible_cpus) {
         assert(ms->possible_cpus->len == max_cpus);
         return ms->possible_cpus;
     }
 
+    cpu_type = qtest_enabled() ? ARM_CPU_TYPE_NAME("max") : ms->cpu_type;
     ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
                                   sizeof(CPUArchId) * max_cpus);
     ms->possible_cpus->len = max_cpus;
     for (n = 0; n < ms->possible_cpus->len; n++) {
-        ms->possible_cpus->cpus[n].type = ms->cpu_type;
+        ms->possible_cpus->cpus[n].type = cpu_type;
         ms->possible_cpus->cpus[n].arch_id =
             arm_build_mp_affinity(n, GICV3_TARGETLIST_BITS);
         ms->possible_cpus->cpus[n].props.has_thread_id = true;
Signature · 1 line
2.47.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Philippe Mathieu-Daudé

First, the VMapple machine only works with the ARM 'host' CPU type, which isn't accepted for QTest:

  $ qemu-system-aarch64 -M vmapple -accel qtest
  qemu-system-aarch64: The 'host' CPU type can only be used with KVM or HVF

Second, the QTest framework expects machines to be createable without specifying optional arguments, however the VMapple machine requires few of them:

Quoted 8 lines
  $ qemu-system-aarch64 -M vmapple -accel qtest
  qemu-system-aarch64: No firmware specified
  $ qemu-system-aarch64 -M vmapple -accel qtest -bios /dev/null
  qemu-system-aarch64: No AUX device. Please specify one as pflash drive.

Restrict some code path to QTest so we can at least run check-qtest, otherwise we get:

Or add vmapple as an exception in qtest_cb_for_every_machine():

    for (i = 0; machines[i].name != NULL; i++) {
        /* Ignore machines that cannot be used for qtests */
        if (!strncmp("xenfv", machines[i].name, 5) ||
            g_str_equal("xenpv", machines[i].name) ||
            g_str_equal("xenpvh", machines[i].name) ||
            g_str_equal("nitro-enclave", machines[i].name)) {
            continue;
        }
        ...
    }

Anyway:

#2 lore raw
Quoted 23 lines · Fabiano Rosas
Quoted 10 lines · Philippe Mathieu-Daudé

First, the VMapple machine only works with the ARM 'host' CPU type, which isn't accepted for QTest:

   $ qemu-system-aarch64 -M vmapple -accel qtest
   qemu-system-aarch64: The 'host' CPU type can only be used with KVM or HVF

Second, the QTest framework expects machines to be createable without specifying optional arguments, however the VMapple machine requires few of them:

Quoted 8 lines
   $ qemu-system-aarch64 -M vmapple -accel qtest
   qemu-system-aarch64: No firmware specified
   $ qemu-system-aarch64 -M vmapple -accel qtest -bios /dev/null
   qemu-system-aarch64: No AUX device. Please specify one as pflash drive.

Restrict some code path to QTest so we can at least run check-qtest, otherwise we get:

Or add vmapple as an exception in qtest_cb_for_every_machine():

Quoted 10 lines
     for (i = 0; machines[i].name != NULL; i++) {
         /* Ignore machines that cannot be used for qtests */
         if (!strncmp("xenfv", machines[i].name, 5) ||
             g_str_equal("xenpv", machines[i].name) ||
             g_str_equal("xenpvh", machines[i].name) ||
             g_str_equal("nitro-enclave", machines[i].name)) {
             continue;
         }
         ...
     }

Oh, I was not aware of qtest_cb_for_every_machine(), thanks!