qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 14/54] plugin: add core code


From: Daniel P . Berrangé
Subject: Re: [Qemu-devel] [PATCH v4 14/54] plugin: add core code
Date: Thu, 12 Sep 2019 10:17:39 +0100
User-agent: Mutt/1.12.1 (2019-06-15)

On Wed, Jul 31, 2019 at 05:06:39PM +0100, Alex Bennée wrote:
> From: "Emilio G. Cota" <address@hidden>
> 
> Signed-off-by: Emilio G. Cota <address@hidden>
> [AJB: moved directory and merged various fixes]
> Signed-off-by: Alex Bennée <address@hidden>


> +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 :|



reply via email to

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