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

[Xen-devel] [PATCH 1 of 3 v3] 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.

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 <george.dunlap@xxxxxxxxxxxxx>

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;

_______________________________________________
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®.