qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v2 3/7] plugins: provide helper functions fo


From: Alex Bennée
Subject: Re: [Qemu-devel] [RFC PATCH v2 3/7] plugins: provide helper functions for plugins
Date: Fri, 07 Sep 2018 14:06:44 +0100
User-agent: mu4e 1.1.0; emacs 26.1.50

Pavel Dovgalyuk <address@hidden> writes:

> From: Pavel Dovgalyuk <address@hidden>
>
> This patch adds interface functions that may be called from the loaded 
> plugins.
> Such functions are needed to inspect the VM state and to pass data
> to the QEMU (e.g., QEMU-side logging).
>
> Signed-off-by: Pavel Dovgalyuk <address@hidden>

Reviewed-by: Alex Bennée <address@hidden>

> ---
>  Makefile.target           |    2 +-
>  plugins/include/plugins.h |    6 ++++++
>  plugins/qemulib.c         |   31 +++++++++++++++++++++++++++++++
>  3 files changed, 38 insertions(+), 1 deletion(-)
>  create mode 100644 plugins/qemulib.c
>
> diff --git a/Makefile.target b/Makefile.target
> index 4cffd96..5648c9c 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -93,7 +93,7 @@ all: $(PROGS) stap
>  # cpu emulator library
>  obj-y += exec.o
>  obj-y += accel/
> -obj-$(CONFIG_PLUGINS) += plugins/plugins.o
> +obj-$(CONFIG_PLUGINS) += plugins/plugins.o plugins/qemulib.o
>  obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o 
> tcg/tcg-op-gvec.o
>  obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o
>  obj-$(CONFIG_TCG_INTERPRETER) += tcg/tci.o
> diff --git a/plugins/include/plugins.h b/plugins/include/plugins.h
> index 100a786..fa624ea 100644
> --- a/plugins/include/plugins.h
> +++ b/plugins/include/plugins.h
> @@ -9,4 +9,10 @@ bool plugin_init(const char *args);
>  bool plugin_needs_before_insn(uint64_t pc, void *cpu);
>  void plugin_before_insn(uint64_t pc, void *cpu);
>
> +/* QEMU interface */
> +
> +void qemulib_log(const char *fmt, ...) /*GCC_FMT_ATTR(1, 2)*/;
> +int qemulib_read_memory(void *cpu, uint64_t addr, uint8_t *buf, int len);
> +int qemulib_read_register(void *cpu, uint8_t *mem_buf, int reg);
> +
>  #endif /* PLUGINS_INTERFACE_H */
> diff --git a/plugins/qemulib.c b/plugins/qemulib.c
> new file mode 100644
> index 0000000..eb812c1
> --- /dev/null
> +++ b/plugins/qemulib.c
> @@ -0,0 +1,31 @@
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "cpu.h"
> +#include "qemu/error-report.h"
> +#include "qemu/plugins.h"
> +#include "qemu/log.h"
> +#include "include/plugins.h"
> +
> +void qemulib_log(const char *fmt, ...)
> +{
> +    va_list args;
> +    va_start(args, fmt);
> +    qemu_log_vprintf(fmt, args);
> +    va_end(args);
> +}
> +
> +int qemulib_read_memory(void *cpu, uint64_t addr, uint8_t *buf, int len)
> +{
> +    return cpu_memory_rw_debug(cpu, addr, buf, len, false);
> +}
> +
> +int qemulib_read_register(void *cpu, uint8_t *mem_buf, int reg)
> +{
> +    CPUClass *cc = CPU_GET_CLASS(cpu);
> +
> +    if (reg < cc->gdb_num_core_regs) {
> +        return cc->gdb_read_register(cpu, mem_buf, reg);
> +    }
> +
> +    return 0;
> +}


--
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]