On Wed, Jul 31, 2019 at 05:06:39PM +0100, Alex Bennée wrote: > From: "Emilio G. Cota" <c...@braap.org> > > Signed-off-by: Emilio G. Cota <c...@braap.org> > [AJB: moved directory and merged various fixes] > Signed-off-by: Alex Bennée <alex.ben...@linaro.org>
> +static int plugin_load(struct qemu_plugin_desc *desc) > +{ > + qemu_plugin_install_func_t install; > + struct qemu_plugin_ctx *ctx; > + char *err; > + int rc; > + > + ctx = qemu_memalign(qemu_dcache_linesize, sizeof(*ctx)); > + memset(ctx, 0, sizeof(*ctx)); > + ctx->desc = desc; > + > + ctx->handle = dlopen(desc->path, RTLD_NOW); > + if (ctx->handle == NULL) { > + error_report("%s: %s", __func__, dlerror()); > + goto err_dlopen; > + } > + > + /* clear any previous dlerror, call dlsym, then check dlerror */ > + dlerror(); > + install = dlsym(ctx->handle, "qemu_plugin_install"); If you use 'GModule' instead of dlopen, then we get portability to many more platforms, including ablity to load DLLs on Windows: https://developer.gnome.org/glib/stable/glib-Dynamic-Loading-of-Modules.html Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|