]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: Look for bootloader in libexec path
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Tue, 15 May 2012 15:28:10 +0000 (16:28 +0100)
committerGeorge Dunlap <george.dunlap@eu.citrix.com>
Tue, 15 May 2012 15:28:10 +0000 (16:28 +0100)
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 <george.dunlap@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_bootloader.c

index fb1302b61b372d2d2cd2010810f0b7d233960100..d695ae0d27fa40de00bdd0530ad67b831382b2b9 100644 (file)
@@ -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;