[RFC PATCH-for-10.0] hw/vmapple: Allow running QTest framework on macOS

Philippe Mathieu-Daudé posted 1 patch 7 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250401090607.36375-1-philmd@linaro.org
Maintainers: Alexander Graf <agraf@csgraf.de>, Phil Dennis-Jordan <phil@philjordan.eu>
hw/vmapple/vmapple.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
[RFC PATCH-for-10.0] hw/vmapple: Allow running QTest framework on macOS
Posted by Philippe Mathieu-Daudé 7 months, 2 weeks ago
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

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/vmapple/vmapple.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
index fa117bf1511..e16c0c72fe5 100644
--- a/hw/vmapple/vmapple.c
+++ b/hw/vmapple/vmapple.c
@@ -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;
-- 
2.47.1


Re: [RFC PATCH-for-10.0] hw/vmapple: Allow running QTest framework on macOS
Posted by Fabiano Rosas 7 months, 2 weeks ago
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> 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:

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:

Acked-by: Fabiano Rosas <farosas@suse.de>
Re: [RFC PATCH-for-10.0] hw/vmapple: Allow running QTest framework on macOS
Posted by Philippe Mathieu-Daudé 7 months, 2 weeks ago
On 1/4/25 15:20, Fabiano Rosas wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 
>> 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:
> 
> 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;
>          }
>          ...
>      }

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