debuggers.hg

changeset 21283:a167ea374f26

libxl: Expose build-time install paths inside libxl.

Use this to construct the fully-qualified path to xenconsole.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 29 19:38:52 2010 +0100 (2010-04-29)
parents 9a1d7caa2024
children 99a85cb72c9f
files .hgignore tools/libxl/Makefile tools/libxl/libxl.c tools/libxl/libxl_internal.h tools/libxl/libxl_paths.c
line diff
     1.1 --- a/.hgignore	Mon Apr 26 12:13:23 2010 +0100
     1.2 +++ b/.hgignore	Thu Apr 29 19:38:52 2010 +0100
     1.3 @@ -180,6 +180,7 @@
     1.4  ^tools/libxen/libxenapi-
     1.5  ^tools/libxen/test/test_bindings$
     1.6  ^tools/libxen/test/test_event_handling$
     1.7 +^tools/libxl/_.*\.h$
     1.8  ^tools/libxl/libxlu_cfg_y\.output$
     1.9  ^tools/libxl/xl$
    1.10  ^tools/libaio/src/.*\.ol$
     2.1 --- a/tools/libxl/Makefile	Mon Apr 26 12:13:23 2010 +0100
     2.2 +++ b/tools/libxl/Makefile	Thu Apr 29 19:38:52 2010 +0100
     2.3 @@ -17,7 +17,7 @@ CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_
     2.4  
     2.5  LIBS = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore)
     2.6  
     2.7 -LIBXL_OBJS-y = osdeps.o
     2.8 +LIBXL_OBJS-y = osdeps.o libxl_paths.o
     2.9  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)
    2.10  
    2.11  AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h
    2.12 @@ -43,6 +43,15 @@ all: $(CLIENTS) libxenlight.so libxenlig
    2.13  %.c: %.l
    2.14  	$(FLEX) --header-file=$*.h --outfile=$@ $<
    2.15  
    2.16 +genpath-target = $(call buildmakevars2file,_libxl_paths.h)
    2.17 +$(eval $(genpath-target))
    2.18 +
    2.19 +_libxl_paths.h: genpath
    2.20 +	sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" $@ >_$@
    2.21 +	mv _$@ $@
    2.22 +
    2.23 +libxl_paths.c: _libxl_paths.h
    2.24 +
    2.25  libxenlight.so: libxenlight.so.$(MAJOR)
    2.26  	ln -sf $< $@
    2.27  
    2.28 @@ -88,7 +97,7 @@ install: all
    2.29  
    2.30  .PHONY: clean
    2.31  clean:
    2.32 -	$(RM) -f *.o *.so* *.a $(CLIENTS) $(DEPS)
    2.33 +	$(RM) -f _*.h *.o *.so* *.a $(CLIENTS) $(DEPS)
    2.34  #	$(RM) -f $(AUTOSRCS) $(AUTOINCS)
    2.35  
    2.36  distclean: clean
     3.1 --- a/tools/libxl/libxl.c	Mon Apr 26 12:13:23 2010 +0100
     3.2 +++ b/tools/libxl/libxl.c	Thu Apr 29 19:38:52 2010 +0100
     3.3 @@ -739,16 +739,9 @@ int libxl_domain_destroy(struct libxl_ct
     3.4  
     3.5  int libxl_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num)
     3.6  {
     3.7 -    struct stat st;
     3.8 -    const char *XENCONSOLE = "/usr/lib/xen/bin/xenconsole";
     3.9 -    char *cmd;
    3.10 -
    3.11 -    if (stat(XENCONSOLE, &st) != 0) {
    3.12 -        XL_LOG(ctx, XL_LOG_ERROR, "could not access %s", XENCONSOLE);
    3.13 -        return ERROR_FAIL;
    3.14 -    }
    3.15 -
    3.16 -    cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE, domid, cons_num);
    3.17 +    char *cmd = libxl_sprintf(
    3.18 +        ctx, "%s/xenconsole %d --num %d",
    3.19 +        libxl_private_bindir_path(), domid, cons_num);
    3.20      return (system(cmd) != 0) ? ERROR_FAIL : 0;
    3.21  }
    3.22  
     4.1 --- a/tools/libxl/libxl_internal.h	Mon Apr 26 12:13:23 2010 +0100
     4.2 +++ b/tools/libxl/libxl_internal.h	Thu Apr 29 19:38:52 2010 +0100
     4.3 @@ -202,5 +202,16 @@ void libxl_exec(int stdinfd, int stdoutf
     4.4  void libxl_log_child_exitstatus(struct libxl_ctx *ctx,
     4.5                                  const char *what, pid_t pid, int status);
     4.6  
     4.7 +/* libxl_paths.c */
     4.8 +const char *libxl_sbindir_path(void);
     4.9 +const char *libxl_bindir_path(void);
    4.10 +const char *libxl_libexec_path(void);
    4.11 +const char *libxl_libdir_path(void);
    4.12 +const char *libxl_sharedir_path(void);
    4.13 +const char *libxl_private_bindir_path(void);
    4.14 +const char *libxl_xenfirmwaredir_path(void);
    4.15 +const char *libxl_xen_config_dir_path(void);
    4.16 +const char *libxl_xen_script_dir_path(void);
    4.17 +
    4.18  #endif
    4.19  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/libxl/libxl_paths.c	Thu Apr 29 19:38:52 2010 +0100
     5.3 @@ -0,0 +1,61 @@
     5.4 +/*
     5.5 + * Copyright (C) 2010      Citrix Ltd.
     5.6 + *
     5.7 + * This program is free software; you can redistribute it and/or modify
     5.8 + * it under the terms of the GNU Lesser General Public License as published
     5.9 + * by the Free Software Foundation; version 2.1 only. with the special
    5.10 + * exception on linking described in file LICENSE.
    5.11 + *
    5.12 + * This program is distributed in the hope that it will be useful,
    5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.15 + * GNU Lesser General Public License for more details.
    5.16 + */
    5.17 +
    5.18 +#include "_libxl_paths.h"
    5.19 +
    5.20 +const char *libxl_sbindir_path(void)
    5.21 +{
    5.22 +    return SBINDIR;
    5.23 +}
    5.24 +
    5.25 +const char *libxl_bindir_path(void)
    5.26 +{
    5.27 +    return BINDIR;
    5.28 +}
    5.29 +
    5.30 +const char *libxl_libexec_path(void)
    5.31 +{
    5.32 +    return LIBEXEC;
    5.33 +}
    5.34 +
    5.35 +const char *libxl_libdir_path(void)
    5.36 +{
    5.37 +    return LIBDIR;
    5.38 +}
    5.39 +
    5.40 +const char *libxl_sharedir_path(void)
    5.41 +{
    5.42 +    return SHAREDIR;
    5.43 +}
    5.44 +
    5.45 +const char *libxl_private_bindir_path(void)
    5.46 +{
    5.47 +    return PRIVATE_BINDIR;
    5.48 +}
    5.49 +
    5.50 +const char *libxl_xenfirmwaredir_path(void)
    5.51 +{
    5.52 +    return XENFIRMWAREDIR;
    5.53 +}
    5.54 +
    5.55 +const char *libxl_xen_config_dir_path(void)
    5.56 +{
    5.57 +    return XEN_CONFIG_DIR;
    5.58 +}
    5.59 +
    5.60 +const char *libxl_xen_script_dir_path(void)
    5.61 +{
    5.62 +    return XEN_SCRIPT_DIR;
    5.63 +}
    5.64 +