]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: Expose build-time install paths inside libxl.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 29 Apr 2010 18:38:52 +0000 (19:38 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 29 Apr 2010 18:38:52 +0000 (19:38 +0100)
Use this to construct the fully-qualified path to xenconsole.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
.hgignore
tools/libxl/Makefile
tools/libxl/libxl.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_paths.c [new file with mode: 0644]

index ac47be625dda72942081c311db9e8e5dc1b784ec..88d6de012432db76e2f1b533a2db7ab1a7fb2c60 100644 (file)
--- a/.hgignore
+++ b/.hgignore
 ^tools/libxen/libxenapi-
 ^tools/libxen/test/test_bindings$
 ^tools/libxen/test/test_event_handling$
+^tools/libxl/_.*\.h$
 ^tools/libxl/libxlu_cfg_y\.output$
 ^tools/libxl/xl$
 ^tools/libaio/src/.*\.ol$
index 75ac02aa477966bb7a7455314e8be550119464fb..df2e1fbe3db3c46b38ad32c750443f6435ba597b 100644 (file)
@@ -17,7 +17,7 @@ CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
 
 LIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore)
 
-LIBXL_OBJS-y = osdeps.o
+LIBXL_OBJS-y = osdeps.o libxl_paths.o
 LIBXL_OBJS = flexarray.o libxl.o libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o libxl_internal.o xenguest.o libxl_utils.o $(LIBXL_OBJS-y)
 
 AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
@@ -43,6 +43,15 @@ $(LIBXLU_OBJS): $(AUTOINCS)
 %.c: %.l
        $(FLEX) --header-file=$*.h --outfile=$@ $<
 
+genpath-target = $(call buildmakevars2file,_libxl_paths.h)
+$(eval $(genpath-target))
+
+_libxl_paths.h: genpath
+       sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" $@ >_$@
+       mv _$@ $@
+
+libxl_paths.c: _libxl_paths.h
+
 libxenlight.so: libxenlight.so.$(MAJOR)
        ln -sf $< $@
 
@@ -88,7 +97,7 @@ install: all
 
 .PHONY: clean
 clean:
-       $(RM) -f *.o *.so* *.a $(CLIENTS) $(DEPS)
+       $(RM) -f _*.h *.o *.so* *.a $(CLIENTS) $(DEPS)
 #      $(RM) -f $(AUTOSRCS) $(AUTOINCS)
 
 distclean: clean
index 1d42f3cf34db5b9b914dd58695c732d900ba5200..620128d155a1ddddac2fb83763a5c1b7b85ff215 100644 (file)
@@ -739,16 +739,9 @@ int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force)
 
 int libxl_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num)
 {
-    struct stat st;
-    const char *XENCONSOLE = "/usr/lib/xen/bin/xenconsole";
-    char *cmd;
-
-    if (stat(XENCONSOLE, &st) != 0) {
-        XL_LOG(ctx, XL_LOG_ERROR, "could not access %s", XENCONSOLE);
-        return ERROR_FAIL;
-    }
-
-    cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE, domid, cons_num);
+    char *cmd = libxl_sprintf(
+        ctx, "%s/xenconsole %d --num %d",
+        libxl_private_bindir_path(), domid, cons_num);
     return (system(cmd) != 0) ? ERROR_FAIL : 0;
 }
 
index 0dc48f1f0878e38e233f296e56726bbb915486b6..3bcae165a8dcd22e3f9e1501f55a97f7c6b63b73 100644 (file)
@@ -202,5 +202,16 @@ 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);
 
+/* libxl_paths.c */
+const char *libxl_sbindir_path(void);
+const char *libxl_bindir_path(void);
+const char *libxl_libexec_path(void);
+const char *libxl_libdir_path(void);
+const char *libxl_sharedir_path(void);
+const char *libxl_private_bindir_path(void);
+const char *libxl_xenfirmwaredir_path(void);
+const char *libxl_xen_config_dir_path(void);
+const char *libxl_xen_script_dir_path(void);
+
 #endif
 
diff --git a/tools/libxl/libxl_paths.c b/tools/libxl/libxl_paths.c
new file mode 100644 (file)
index 0000000..ceb1d73
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010      Citrix Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "_libxl_paths.h"
+
+const char *libxl_sbindir_path(void)
+{
+    return SBINDIR;
+}
+
+const char *libxl_bindir_path(void)
+{
+    return BINDIR;
+}
+
+const char *libxl_libexec_path(void)
+{
+    return LIBEXEC;
+}
+
+const char *libxl_libdir_path(void)
+{
+    return LIBDIR;
+}
+
+const char *libxl_sharedir_path(void)
+{
+    return SHAREDIR;
+}
+
+const char *libxl_private_bindir_path(void)
+{
+    return PRIVATE_BINDIR;
+}
+
+const char *libxl_xenfirmwaredir_path(void)
+{
+    return XENFIRMWAREDIR;
+}
+
+const char *libxl_xen_config_dir_path(void)
+{
+    return XEN_CONFIG_DIR;
+}
+
+const char *libxl_xen_script_dir_path(void)
+{
+    return XEN_SCRIPT_DIR;
+}
+