[Libguestfs] [PATCH nbdkit 2/5] vddk: Move reexec code to a new file.

Eric Blake eblake at redhat.com
Tue Jun 2 14:16:15 UTC 2020


On 6/2/20 7:27 AM, Richard W.M. Jones wrote:
> Pure refactoring.  Just decouples the complicated reexec code from the
> rest.
> ---
>   plugins/vddk/Makefile.am |   2 +
>   plugins/vddk/vddk.h      |  42 +++++++++
>   plugins/vddk/reexec.c    | 196 +++++++++++++++++++++++++++++++++++++++
>   plugins/vddk/vddk.c      | 151 ++----------------------------
>   4 files changed, 246 insertions(+), 145 deletions(-)
> 

> +
> +/* If load_library caused a re-execution with an expanded
> + * LD_LIBRARY_PATH, restore it back to its original contents, passed
> + * as the value of "reexeced_".  dlopen uses the value of

Comment may need a tweak, since the .config parsing of reexeced_ is now 
in a different file, and this file is going solely off the global reexeced.

> + * LD_LIBRARY_PATH cached at program startup; our change is for the
> + * sake of child processes (such as --run) to see the same
> + * environment as the original nbdkit saw before re-exec.
> + */
> +int
> +restore_ld_library_path (void)
> +{
> +  if (reexeced) {
> +    char *env = getenv ("LD_LIBRARY_PATH");
> +
> +    nbdkit_debug ("cleaning up after re-exec");
> +    if (!env || strstr (env, reexeced) == NULL ||
> +        (libdir && strncmp (env, libdir, strlen (libdir)) != 0)) {
> +      nbdkit_error ("'reexeced_' set with garbled environment");

Then again, we are outputting an error message based on what .config saw.

At any rate, the split makes sense.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list