Skip to contentSkip to conversation

system/qtest: Minor include cleanups

PATCH In review Philippe Mathieu-Daudé 2 participants 6 messages Dec 12, 2023 – Dec 26, 2023

lore
Share & tools
lore
#0 lore raw

cover system/qtest: Minor include cleanups

Add missing header and restrict to sysemu.

Philippe Mathieu-Daudé (2):
system/qtest: Include missing 'hw/core/cpu.h' header system/qtest: Restrict QTest API to system emulation

 include/sysemu/qtest.h | 2 ++
 system/qtest.c         | 1 +
 2 files changed, 3 insertions(+)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 system/qtest: Include missing 'hw/core/cpu.h' header

"hw/core/cpu.h" declares 'first_cpu'. Include it to avoid when unrelated headers are refactored:

system/qtest.c:548:33: error: use of undeclared identifier 'first_cpu'

            address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
                                ^
---
 system/qtest.c | 1 +
 1 file changed, 1 insertion(+)
system/qtest.c +1 -0
index 7964f0b248..6da58b3874 100644
@@ -21,6 +21,7 @@
 #include "exec/tswap.h"
 #include "hw/qdev-core.h"
 #include "hw/irq.h"
+#include "hw/core/cpu.h"
 #include "qemu/accel.h"
 #include "sysemu/cpu-timers.h"
 #include "qemu/config-file.h"
Signature · 1 line
2.41.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] system/qtest: Include missing 'hw/core/cpu.h' header

Quoted 17 lines · Philippe Mathieu-Daudé

"hw/core/cpu.h" declares 'first_cpu'. Include it to avoid when unrelated headers are refactored:

   system/qtest.c:548:33: error: use of undeclared identifier 'first_cpu'
             address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
                                 ^
---
  system/qtest.c | 1 +
  1 file changed, 1 insertion(+)
system/qtest.c +0 -0
index 7964f0b248..6da58b3874 100644

system/qtest.c line 27

Quoted 7 lines
system/qtest.c +1 -0
@@ -21,6 +21,7 @@
  #include "exec/tswap.h"
  #include "hw/qdev-core.h"
  #include "hw/irq.h"
+#include "hw/core/cpu.h"
  #include "qemu/accel.h"
  #include "sysemu/cpu-timers.h"
  #include "qemu/config-file.h"
#3 lore raw

PATCH 2/2 system/qtest: Restrict QTest API to system emulation

In reply to Philippe Mathieu-Daudé

Outside of system emulation, only qtest_enabled() can be used.

---
 include/sysemu/qtest.h | 2 ++
 1 file changed, 2 insertions(+)
include/sysemu/qtest.h +2 -0
index 85f05b0e46..b5d5fd3463 100644
@@ -23,6 +23,7 @@ static inline bool qtest_enabled(void)
     return qtest_allowed;
 }
 
+#ifndef CONFIG_USER_ONLY
 void qtest_send_prefix(CharBackend *chr);
 void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr, const char *fmt, ...);
 void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words));
@@ -35,5 +36,6 @@ void qtest_server_set_send_handler(void (*send)(void *, const char *),
 void qtest_server_inproc_recv(void *opaque, const char *buf);
 
 int64_t qtest_get_virtual_clock(void);
+#endif
 
 #endif
Signature · 1 line
2.41.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] system/qtest: Restrict QTest API to system emulation

Quoted 20 lines · Philippe Mathieu-Daudé

Outside of system emulation, only qtest_enabled() can be used.

---
  include/sysemu/qtest.h | 2 ++
  1 file changed, 2 insertions(+)
include/sysemu/qtest.h +1 -0
index 85f05b0e46..b5d5fd3463 100644
@@ -23,6 +23,7 @@ static inline bool qtest_enabled(void)
      return qtest_allowed;
  }
 
+#ifndef CONFIG_USER_ONLY
  void qtest_send_prefix(CharBackend *chr);
  void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr, const char *fmt, ...);
  void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words));

include/sysemu/qtest.h void qtest_server_set_send_handler(void (*send)(void *, const char *), · line 39

Quoted 4 lines
include/sysemu/qtest.h +1 -0
@@ -35,5 +36,6 @@ void qtest_server_set_send_handler(void (*send)(void *, const char *),
  void qtest_server_inproc_recv(void *opaque, const char *buf);
 
  int64_t qtest_get_virtual_clock(void);
+#endif
#5 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

Add missing header and restrict to sysemu.

Philippe Mathieu-Daudé (2):
system/qtest: Include missing 'hw/core/cpu.h' header system/qtest: Restrict QTest API to system emulation

Thanks Thomas for merging these!