Currently all qtest MMIO access are dispatched via the first CPU
available. This limitation doesn't allow use to use the 'none'
machine to run tests. Unleash this limitation by selecting the
global address_space_memory when no CPU is available.

Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
---
 softmmu/qtest.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 81b5110783..7f018d2faf 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -19,6 +19,7 @@
 #include "chardev/char-fe.h"
 #include "exec/ioport.h"
 #include "exec/memory.h"
+#include "exec/address-spaces.h"
 #include "hw/irq.h"
 #include "sysemu/accel.h"
 #include "sysemu/cpus.h"
@@ -276,6 +277,13 @@ static void qtest_irq_handler(void *opaque, int n, int 
level)
 /* Default address space for MMIO accesses */
 static AddressSpace *qtest_mem_as(void)
 {
+    if (!first_cpu) {
+        /*
+         * The 'none' machine doesn't have any CPU,
+         * directly access the main address space.
+         */
+        return &address_space_memory;
+    }
     return first_cpu->as;
 }
 
-- 
2.26.2


Reply via email to