Skip to content

Commit

Permalink
plugin: add qemu_plugin_outs helper
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Aaron Lindsay <[email protected]>
  • Loading branch information
stsquad committed Oct 28, 2019
1 parent cbafa23 commit ca76a66
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/qemu/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions include/qemu/qemu-plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
8 changes: 8 additions & 0 deletions plugins/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions plugins/qemu-plugins.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@
qemu_plugin_vcpu_for_each;
qemu_plugin_n_vcpus;
qemu_plugin_n_max_vcpus;
qemu_plugin_outs;
};
3 changes: 3 additions & 0 deletions util/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
};

Expand Down

0 comments on commit ca76a66

Please sign in to comment.