plugin: add qemu_plugin_outs helper
authorAlex Bennée <alex.bennee@linaro.org>
Fri, 11 Oct 2019 15:34:05 +0000 (16:34 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Mon, 28 Oct 2019 15:12:38 +0000 (15:12 +0000)
Having the plugins grab stdout and spew stuff there is a bit ugly and
certainly makes the tests look ugly. Provide a hook back into QEMU
which can be redirected as needed.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Aaron Lindsay <aaron@os.amperecomputing.com>
include/qemu/log.h
include/qemu/qemu-plugin.h
plugins/api.c
plugins/qemu-plugins.symbols
util/log.c

index b097a6cae114b602763f1011ec2ed3e1ac5fc071..a91105b2adca5bb28e1ff0a04b4480cd446e456e 100644 (file)
@@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void)
 /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */
 #define CPU_LOG_TB_OP_IND  (1 << 16)
 #define CPU_LOG_TB_FPU     (1 << 17)
+#define CPU_LOG_PLUGIN     (1 << 18)
 
 /* Lock output for a series of related logs.  Since this is not needed
  * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we
index ddf267fbfe0416504161ae6c2df517931a6c9f43..a00a7deb4614da8c6e14aaef1f32534417f029d2 100644 (file)
@@ -384,4 +384,10 @@ int qemu_plugin_n_vcpus(void);
 /* returns -1 in user-mode */
 int qemu_plugin_n_max_vcpus(void);
 
+/**
+ * qemu_plugin_outs() - output string via QEMU's logging system
+ * @string: a string
+ */
+void qemu_plugin_outs(const char *string);
+
 #endif /* QEMU_PLUGIN_API_H */
index 5adc4d25a1e49c6ec2e9a2a4325b15eb8af4160a..fa1d9f276d344008821c406a979cd13c076178bf 100644 (file)
@@ -331,3 +331,11 @@ int qemu_plugin_n_max_vcpus(void)
     return get_ms()->smp.max_cpus;
 #endif
 }
+
+/*
+ * Plugin output
+ */
+void qemu_plugin_outs(const char *string)
+{
+    qemu_log_mask(CPU_LOG_PLUGIN, "%s", string);
+}
index 267ec381b4a5de6377289f4961d5da55091c7cc9..4bdb381f48eea72eb57b188af7f40cb6adb79483 100644 (file)
@@ -36,4 +36,5 @@
   qemu_plugin_vcpu_for_each;
   qemu_plugin_n_vcpus;
   qemu_plugin_n_max_vcpus;
+  qemu_plugin_outs;
 };
index 1d1b33f7d9fea621fdcbb89edfc82032003b0bca..1ca13059eef5441dce01769e046d455acf52af3b 100644 (file)
@@ -273,6 +273,9 @@ const QEMULogItem qemu_log_items[] = {
     { CPU_LOG_TB_NOCHAIN, "nochain",
       "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n"
       "complete traces" },
+#ifdef CONFIG_PLUGIN
+    { CPU_LOG_PLUGIN, "plugin", "output from TCG plugins\n"},
+#endif
     { 0, NULL, NULL },
 };