> From: Alex Bennée [mailto:alex.ben...@linaro.org] > Pavel Dovgalyuk <pavel.dovga...@ispras.ru> writes: > > > This patch adds support for dynamically loaded plugins. > > Every plugin is a dynamic library with a set of optional exported > > functions that will be called from QEMU. > > > > Signed-off-by: Pavel Dovgalyuk <pavel.dovga...@ispras.ru> > > --- > > Makefile.target | 1 > > configure | 14 ++++++- > > include/qemu/plugins.h | 8 ++++ > > plugins/include/plugins.h | 12 ++++++ > > plugins/plugins.c | 91 > > +++++++++++++++++++++++++++++++++++++++++++++ > > qemu-options.hx | 10 +++++ > > vl.c | 8 ++++ > > 7 files changed, 143 insertions(+), 1 deletion(-) > > create mode 100644 include/qemu/plugins.h > > create mode 100644 plugins/include/plugins.h > > create mode 100644 plugins/plugins.c > > > > diff --git a/Makefile.target b/Makefile.target > > index dad2cf8..4cffd96 100644 > > --- a/Makefile.target > > +++ b/Makefile.target > > @@ -93,6 +93,7 @@ all: $(PROGS) stap > > # cpu emulator library > > obj-y += exec.o > > obj-y += accel/ > > +obj-$(CONFIG_PLUGINS) += plugins/plugins.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/configure b/configure > > index a71bf9b..34e6f00 100755 > > --- a/configure > > +++ b/configure > > @@ -373,6 +373,7 @@ EXESUF="" > > DSOSUF=".so" > > LDFLAGS_SHARED="-shared" > > modules="no" > > +plugins="no" > > prefix="/usr/local" > > mandir="\${prefix}/share/man" > > datadir="\${prefix}/share" > > @@ -922,6 +923,12 @@ for opt do > > --disable-modules) > > modules="no" > > ;; > > + --enable-plugins) > > + plugins="yes" > > + ;; > > + --disable-plugins) > > + plugins="no" > > + ;; > > --cpu=*) > > ;; > > --target-list=*) target_list="$optarg" > > @@ -1567,6 +1574,7 @@ disabled with --disable-FEATURE, default is enabled > > if available: > > guest-agent-msi build guest agent Windows MSI installation package > > pie Position Independent Executables > > modules modules support > > + plugins plugins support > > debug-tcg TCG debugging (default is disabled) > > debug-info debugging information > > sparse sparse checker > > @@ -3392,7 +3400,7 @@ else > > glib_req_ver=2.22 > > fi > > glib_modules=gthread-2.0 > > -if test "$modules" = yes; then > > +if test "$modules" = yes || test "$plugins" = yes; then > > glib_modules="$glib_modules gmodule-export-2.0" > > fi > > > > @@ -5777,6 +5785,7 @@ if test "$slirp" = "yes" ; then > > echo "smbd $smbd" > > fi > > echo "module support $modules" > > +echo "plugin support $plugins" > > echo "host CPU $cpu" > > echo "host big endian $bigendian" > > echo "target list $target_list" > > @@ -6111,6 +6120,9 @@ if test "$modules" = "yes"; then > > echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | > > $shacmd - | cut - > f1 -d\ )" >> $config_host_mak > > echo "CONFIG_MODULES=y" >> $config_host_mak > > fi > > +if test "$plugins" = "yes"; then > > + echo "CONFIG_PLUGINS=y" >> $config_host_mak > > +fi > > if test "$have_x11" = "yes" -a "$need_x11" = "yes"; then > > echo "CONFIG_X11=y" >> $config_host_mak > > echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak > > diff --git a/include/qemu/plugins.h b/include/qemu/plugins.h > > new file mode 100644 > > index 0000000..4464822 > > --- /dev/null > > +++ b/include/qemu/plugins.h > > @@ -0,0 +1,8 @@ > > +#ifndef PLUGINS_H > > +#define PLUGINS_H > > + > > +void qemu_plugin_parse_cmd_args(const char *optarg); > > +void qemu_plugin_load(const char *filename, const char *args); > > +void qemu_plugins_init(void); > > I think you want to have an #ifdef CONFIG_PLUGINS here and some empty > inlines for the non CONFIG_PLUGINS case so you don't need to ifdef so > much later.
Thanks. I'll better fix init, because all other invocations are command-line dependent and still should be put under ifdef. > > @@ -4470,6 +4476,8 @@ int main(int argc, char **argv, char **envp) > > } > > parse_numa_opts(current_machine); > > > > + qemu_plugins_init(); > > + > > For example this fails to build currently. > Pavel Dovgalyuk