From: George Dunlap Subject: [PATCH 1 of 3 v3] libxl: Look for bootloader in libexec path Date: Tue, 15 May 2012 15:22:54 +0100 Message-ID: <52ff381a0bba98fc4d21.1337091774@kodo2> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: george.dunlap@eu.citrix.com List-Id: xen-devel@lists.xenproject.org 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. v3: - Port to xen-unstable tip - Take out now-unnecessary check for malloc failure Signed-off-by: George Dunlap diff -r edd7c7ad1ad2 -r 52ff381a0bba tools/libxl/libxl_bootloader.c --- a/tools/libxl/libxl_bootloader.c Tue May 15 09:18:33 2012 +0200 +++ b/tools/libxl/libxl_bootloader.c Tue May 15 15:13:36 2012 +0100 @@ -336,6 +336,26 @@ void libxl__bootloader_run(libxl__egc *e 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;