From: George Dunlap Date: Tue, 15 May 2012 15:28:10 +0000 (+0100) Subject: libxl: Look for bootloader in libexec path X-Git-Tag: 4.2.0-rc1~348 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=965932f9fe938c408bcc3330a7db29fbab3964a8;p=xen.git libxl: Look for bootloader in libexec path 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. Signed-off-by: George Dunlap Committed-by: Ian Campbell --- diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index fb1302b61b..d695ae0d27 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -336,6 +336,26 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) goto out; } + LOG(DEBUG, "Config bootloader value: %s", info->u.pv.bootloader); + + /* If the full path is not specified, check in the libexec path */ + if ( info->u.pv.bootloader[0] != '/' ) { + char *bootloader; + struct stat st; + + bootloader = libxl__abs_path(gc, info->u.pv.bootloader, + libxl__libexec_path()); + /* Check to see if the file exists in this location; if not, + * fall back to checking the path */ + LOG(DEBUG, "Checking for bootloader in libexec path: %s", bootloader); + + if ( lstat(bootloader, &st) ) + LOG(DEBUG, "%s doesn't exist, falling back to config path", + bootloader); + else + info->u.pv.bootloader = bootloader; + } + make_bootloader_args(gc, bl); bl->openpty.ao = ao;