libxl: make use of libxl path functions
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 6 May 2010 14:59:35 +0000 (15:59 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 6 May 2010 14:59:35 +0000 (15:59 +0100)
Make use of the new libxl_*_path functions to specify the correct
absolute path of qemu-dm, hvmloader and ioemu-stubdom.gz.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.c
tools/libxl/libxl_internal.h

index 3a9f3d091e9ffbe5d715f5eaee192d10887a7de5..a660ab904b4030007baa693b1706befb61e73fa3 100644 (file)
@@ -981,7 +981,7 @@ static int libxl_create_stubdom(struct libxl_ctx *ctx,
     b_info.max_vcpus = 1;
     b_info.max_memkb = 32 * 1024;
     b_info.target_memkb = b_info.max_memkb;
-    b_info.kernel = "/usr/lib/xen/boot/ioemu-stubdom.gz";
+    b_info.kernel = libxl_abs_path(ctx, "ioemu-stubdom.gz", libxl_xenfirmwaredir_path());
     b_info.u.pv.cmdline = libxl_sprintf(ctx, " -d %d", info->domid);
     b_info.u.pv.ramdisk = "";
     b_info.u.pv.features = "";
@@ -1122,7 +1122,8 @@ int libxl_create_device_model(struct libxl_ctx *ctx,
     if (rc < 0) goto xit;
     if (!rc) { /* inner child */
         libxl_exec(null, logfile_w, logfile_w,
-                   info->device_model, args);
+                   libxl_abs_path(ctx, info->device_model, libxl_private_bindir_path()),
+                   args);
     }
 
     rc = 0;
@@ -1702,7 +1703,7 @@ static int libxl_build_xenpv_qemu_args(struct libxl_ctx *ctx,
     }
     info->domid = vfb->domid;
     info->dom_name = libxl_domid_to_name(ctx, vfb->domid);
-    info->device_model = "/usr/lib/xen/bin/qemu-dm";
+    info->device_model = libxl_abs_path(ctx, "qemu-dm", libxl_private_bindir_path());
     info->type = XENPV;
     return 0;
 }
index 89ba8b9a347e9d8c9bf01056d3eb9643facb2bfa..a4f2087786028038bb9d2a951ea0bcb6b961737c 100644 (file)
@@ -171,7 +171,13 @@ int build_hvm(struct libxl_ctx *ctx, uint32_t domid,
 {
     int ret;
 
-    ret = xc_hvm_build_target_mem(ctx->xch, domid, (info->max_memkb - info->video_memkb) / 1024, (info->target_memkb - info->video_memkb) / 1024, info->kernel);
+    ret = xc_hvm_build_target_mem(
+        ctx->xch,
+        domid,
+        (info->max_memkb - info->video_memkb) / 1024,
+        (info->target_memkb - info->video_memkb) / 1024,
+        libxl_abs_path(ctx, (char *)info->kernel,
+                       libxl_xenfirmwaredir_path()));
     if (ret) {
         XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm building failed");
         return ERROR_FAIL;
index 4dcdabe6534c99e1dc99fc766cb1495b3d6280d8..421e1e74901033dd93f5041c5c1c0c8d7773383d 100644 (file)
@@ -194,3 +194,11 @@ void xl_log(struct libxl_ctx *ctx, int loglevel, int errnoval,
     xl_logv(ctx, loglevel, errnoval, file, line, func, fmt, ap);
     va_end(ap);
 }
+
+char *libxl_abs_path(struct libxl_ctx *ctx, char *s, const char *path)
+{
+    if (!s || s[0] == '/')
+        return s;
+    return libxl_sprintf(ctx, "%s/%s", path, s);
+}
+
index ce535fdcdf85dbac44d601d9a38bf173c2f99b92..d75a250f3c7a1196166f16a6392f12b4b0196ee1 100644 (file)
@@ -202,6 +202,8 @@ void libxl_exec(int stdinfd, int stdoutfd, int stderrfd, char *arg0, char **args
 void libxl_log_child_exitstatus(struct libxl_ctx *ctx,
                                 const char *what, pid_t pid, int status);
 
+char *libxl_abs_path(struct libxl_ctx *ctx, char *s, const char *path);
+
 /* libxl_paths.c */
 const char *libxl_sbindir_path(void);
 const char *libxl_bindir_path(void);