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

Re: [Xen-devel] [PATCH 1 of 3 v2] libxl: Look for bootloader in libexec path



On Tue, 2012-05-15 at 11:33 +0100, George Dunlap wrote:
> If the full path for a bootloader (such as pygrub or xenpvnetboot) is not
> given, check for it first in the libexec path before falling back to the
> PATH variable.
> 
> v2:
>  - Check for the libexec path, and if the bootloader isn't there, fall back to
>    the explicitly passed value.  If the full path isn't specified, this will
>    case execvp to search using the path given in the PATH variable.
> 
> Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
> 
> diff -r 84ae90427c54 -r 662e2f6be283 tools/libxl/libxl_bootloader.c
> --- a/tools/libxl/libxl_bootloader.c  Fri May 11 17:46:16 2012 +0100
> +++ b/tools/libxl/libxl_bootloader.c  Tue May 15 11:20:53 2012 +0100
> @@ -333,6 +333,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
>  
>      char tempdir_template[] = "/var/run/libxl/bl.XXXXXX";
>      char *tempdir;
> +    const char *bootloader = NULL;
>  
>      char *dom_console_xs_path;
>      char dom_console_slave_tty_path[PATH_MAX];
> @@ -397,6 +398,30 @@ int libxl_run_bootloader(libxl_ctx *ctx,
>          goto out_close;
>      }
>  
> +    LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Config bootloader path: %s",
> +               info->u.pv.bootloader);
> +
> +    bootloader = libxl__abs_path(gc, info->u.pv.bootloader,
> +                                 libxl__libexec_path());
> +    if ( bootloader == NULL ) {

Since you seem to be respinning anyway...

This can't actually happen any more, since 25181:26f72d923cb9 (libxl:
Crash (more sensibly) on malloc failure)


> +        rc = ERROR_NOMEM;
> +        goto out_close;
> +    } else {
> +        /* Check to see if the file exists in this location; if not,  fall 
> back
> +         * to checking the path */
> +        struct stat st;
> +
> +        LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Resulting bootloader path: %s",
> +                   bootloader);
> +
> +        if ( lstat(bootloader, &st) )
> +        {
> +            LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "%s doesn't exist, will search 
> $PATH",
> +                       bootloader);
> +            bootloader = info->u.pv.bootloader;
> +        }
> +    }
> +
>      /*
>       * We need to present the bootloader's tty as a pty slave that xenconsole
>       * can access.  Since the bootloader itself needs a pty slave,
> @@ -417,7 +442,7 @@ int libxl_run_bootloader(libxl_ctx *ctx,
>      dom_console_xs_path = libxl__sprintf(gc, "%s/console/tty", 
> libxl__xs_get_dompath(gc, domid));
>      libxl__xs_write(gc, XBT_NULL, dom_console_xs_path, "%s", 
> dom_console_slave_tty_path);
>  
> -    pid = fork_exec_bootloader(&bootloader_fd, info->u.pv.bootloader, args);
> +    pid = fork_exec_bootloader(&bootloader_fd, bootloader, args);
>      if (pid < 0) {
>          goto out_close;
>      }
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.