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

[Xen-devel] [PATCH] libxl: remove lockdir and config dir from the API



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1338292617 -3600
# Node ID 12537c670e9ea9e7f73747e203ca318107b82cd9
# Parent  5b6848336d6f98f8ae7350e913245e73887b69f1
libxl: remove lockdir and config dir from the API

These are only used by xl.

Rename _libxl_paths.h -> _paths.h, these are not actually "libxl" paths but
rather are part of the Xen build time configuration. It is fine for xl to also
consume them.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 5b6848336d6f -r 12537c670e9e tools/libxl/Makefile
--- a/tools/libxl/Makefile      Tue May 29 11:41:52 2012 +0100
+++ b/tools/libxl/Makefile      Tue May 29 12:56:57 2012 +0100
@@ -103,10 +103,10 @@ all: $(CLIENTS) libxenlight.so libxenlig
        @rm -f $*.[ch]
        $(FLEX) --header-file=$*.h --outfile=$*.c $<
 
-genpath-target = $(call buildmakevars2file,_libxl_paths.h.tmp)
+genpath-target = $(call buildmakevars2file,_paths.h.tmp)
 $(eval $(genpath-target))
 
-_libxl_paths.h: genpath
+_paths.h: genpath
        sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" $@.tmp >$@.2.tmp
        rm -f $@.tmp
        $(call move-if-changed,$@.2.tmp,$@)
@@ -117,7 +117,7 @@ _libxl_list.h: $(XEN_INCLUDE)/xen-extern
 
 libxl.h: _libxl_types.h
 libxl_json.h: _libxl_types_json.h
-libxl_internal.h: _libxl_types_internal.h _libxl_paths.h
+libxl_internal.h: _libxl_types_internal.h _paths.h
 libxl_internal_json.h: _libxl_types_internal_json.h
 
 $(LIBXL_OBJS) $(LIBXLU_OBJS) $(XL_OBJS): libxl.h
@@ -181,7 +181,7 @@ install: all
 .PHONY: clean
 clean:
        $(RM) -f _*.h *.o *.so* *.a $(CLIENTS) $(DEPS)
-       $(RM) -f _*.c *.pyc _libxl_paths.*.tmp
+       $(RM) -f _*.c *.pyc _paths.*.tmp
        $(RM) -f testidl.c.new testidl.c
 #      $(RM) -f $(AUTOSRCS) $(AUTOINCS)
 
diff -r 5b6848336d6f -r 12537c670e9e tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Tue May 29 11:41:52 2012 +0100
+++ b/tools/libxl/libxl.h       Tue May 29 12:56:57 2012 +0100
@@ -840,10 +840,6 @@ int libxl_flask_getenforce(libxl_ctx *ct
 int libxl_flask_setenforce(libxl_ctx *ctx, int mode);
 int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
 
-/* common paths */
-const char *libxl_xen_config_dir_path(void);
-const char *libxl_lock_dir_path(void);
-
 /* misc */
 
 /* Each of these sets or clears the flag according to whether the
diff -r 5b6848336d6f -r 12537c670e9e tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Tue May 29 11:41:52 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Tue May 29 12:56:57 2012 +0100
@@ -52,7 +52,7 @@
 #include <xen/io/xenbus.h>
 
 #include "libxl.h"
-#include "_libxl_paths.h"
+#include "_paths.h"
 
 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
 #define _hidden __attribute__((visibility("hidden")))
diff -r 5b6848336d6f -r 12537c670e9e tools/libxl/libxl_paths.c
--- a/tools/libxl/libxl_paths.c Tue May 29 11:41:52 2012 +0100
+++ b/tools/libxl/libxl_paths.c Tue May 29 12:56:57 2012 +0100
@@ -30,21 +30,11 @@ const char *libxl__xenfirmwaredir_path(v
     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;
 }
 
-const char *libxl_lock_dir_path(void)
-{
-    return XEN_LOCK_DIR;
-}
-
 const char *libxl__run_dir_path(void)
 {
     return XEN_RUN_DIR;
diff -r 5b6848336d6f -r 12537c670e9e tools/libxl/xl.c
--- a/tools/libxl/xl.c  Tue May 29 11:41:52 2012 +0100
+++ b/tools/libxl/xl.c  Tue May 29 12:56:57 2012 +0100
@@ -72,11 +72,12 @@ static void parse_global_config(const ch
     if (!xlu_cfg_get_string (config, "lockfile", &buf, 0))
         lockfile = strdup(buf);
     else {
-        e = asprintf(&lockfile, "%s/xl", (char *)libxl_lock_dir_path());
-        if (e < 0) {
-            fprintf(stderr, "asprintf memory allocation failed\n");
-            exit(1);
-        }
+        lockfile = strdup(XL_LOCK_FILE);
+    }
+
+    if (!lockfile < 0) {
+        fprintf(stderr, "failed to allocate lockdir \n");
+        exit(1);
     }
 
     if (!xlu_cfg_get_string (config, "vifscript", &buf, 0))
@@ -189,7 +190,6 @@ int main(int argc, char **argv)
     char *cmd = 0;
     struct cmd_spec *cspec;
     int ret;
-    char *config_file;
     void *config_data = 0;
     int config_len = 0;
     const char *locks[] = XEND_LOCK;
@@ -224,20 +224,12 @@ int main(int argc, char **argv)
 
     xl_ctx_alloc();
 
-    /* Read global config file options */
-    ret = asprintf(&config_file, "%s/xl.conf", libxl_xen_config_dir_path());
-    if (ret < 0) {
-        fprintf(stderr, "memory allocation failed ret=%d, errno=%d\n", ret, 
errno);
-        exit(1);
-    }
-
-    ret = libxl_read_file_contents(ctx, config_file,
+    ret = libxl_read_file_contents(ctx, XL_GLOBAL_CONFIG,
             &config_data, &config_len);
     if (ret)
         fprintf(stderr, "Failed to read config file: %s: %s\n",
-                config_file, strerror(errno));
-    parse_global_config(config_file, config_data, config_len);
-    free(config_file);
+                XL_GLOBAL_CONFIG, strerror(errno));
+    parse_global_config(XL_GLOBAL_CONFIG, config_data, config_len);
     free(config_data);
 
     /* Reset options for per-command use of getopt. */
diff -r 5b6848336d6f -r 12537c670e9e tools/libxl/xl.h
--- a/tools/libxl/xl.h  Tue May 29 11:41:52 2012 +0100
+++ b/tools/libxl/xl.h  Tue May 29 12:56:57 2012 +0100
@@ -17,6 +17,7 @@
 
 #include <assert.h>
 
+#include "_paths.h"
 #include "xentoollog.h"
 
 struct cmd_spec {
@@ -152,6 +153,9 @@ extern enum output_format default_output
 
 extern void printf_info_sexp(int domid, libxl_domain_config *d_config);
 
+#define XL_GLOBAL_CONFIG XEN_CONFIG_DIR "/xl.conf"
+#define XL_LOCK_FILE XEN_LOCK_DIR "/xl"
+
 #endif /* XL_H */
 
 /*

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