Mailing List Archive

[xen-unstable] Add xl init scripts
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1275890754 -3600
# Node ID 6e53bd71bfb2abceb3d8cf8ffcc9084d70fb9c1b
# Parent efa8d417e1a0758eeb338eb154d33b72dad7f291
Add xl init scripts

this patch adds an init script for xl, so that it can be used without
xend installed on the system. In cases in which both toolstacks are
present, only one init script will be run, dependening on the value of
xen_toolstack in /etc/sysconfig/xen_toolstack. Please note that a
correct value of xen_toolstack (either xl or xend), is required now.
The network script and the vif script to be used with xl can be
specified in /etc/sysconfig/xenlightdaemons. Xl sets the vif script
to xl-vif-script by default, that reads /etc/sysconfig/xenlightdaemons
and calls the vif script set there. A port to a debian system should
be straightforward, just replacing /etc/sysconfig with /etc/default
everywhere.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
tools/hotplug/Linux/Makefile | 8 ++++++
tools/hotplug/Linux/init.d/xend | 6 +++++
tools/hotplug/Linux/init.d/xendomains | 7 +++++
tools/hotplug/Linux/xl-vif-script | 14 +++++++++++
tools/libxl/libxl.h | 12 ++++++++++
tools/libxl/libxl_internal.h | 11 ---------
tools/libxl/xl_cmdimpl.c | 40 +++++++++++++++++-----------------
7 files changed, 68 insertions(+), 30 deletions(-)

diff -r efa8d417e1a0 -r 6e53bd71bfb2 tools/hotplug/Linux/Makefile
--- a/tools/hotplug/Linux/Makefile Mon Jun 07 06:56:04 2010 +0100
+++ b/tools/hotplug/Linux/Makefile Mon Jun 07 07:05:54 2010 +0100
@@ -7,10 +7,15 @@ XENDOMAINS_INITD = init.d/xendomains
XENDOMAINS_INITD = init.d/xendomains
XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains

+XLD_INITD = init.d/xenlightdaemons
+XLD_SYSCONFIG = init.d/sysconfig.xenlightdaemons
+XENTOOLSTACK_SYSCONFIG = init.d/sysconfig.xen_toolstack
+
# Xen script dir and scripts to go there.
XEN_SCRIPTS = network-bridge vif-bridge
XEN_SCRIPTS += network-route vif-route
XEN_SCRIPTS += network-nat vif-nat
+XEN_SCRIPTS += xl-vif-script
XEN_SCRIPTS += vif2
XEN_SCRIPTS += block
XEN_SCRIPTS += block-enbd block-nbd
@@ -67,6 +72,9 @@ install-initd:
$(INSTALL_PROG) $(XEND_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xend
$(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
$(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xendomains
+ $(INSTALL_PROG) $(XLD_INITD) $(DESTDIR)$(CONFIG_DIR)/init.d
+ $(INSTALL_PROG) $(XLD_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xenlightdaemons
+ $(INSTALL_PROG) $(XENTOOLSTACK_SYSCONFIG) $(DESTDIR)$(CONFIG_DIR)/sysconfig/xen_toolstack

.PHONY: install-scripts
install-scripts:
diff -r efa8d417e1a0 -r 6e53bd71bfb2 tools/hotplug/Linux/init.d/xend
--- a/tools/hotplug/Linux/init.d/xend Mon Jun 07 06:56:04 2010 +0100
+++ b/tools/hotplug/Linux/init.d/xend Mon Jun 07 07:05:54 2010 +0100
@@ -21,6 +21,12 @@

shopt -s extglob
test -f /etc/sysconfig/xend && . /etc/sysconfig/xend
+test -f /etc/sysconfig/xen_toolstack && . /etc/sysconfig/xen_toolstack
+
+if test "x$xen_toolstack" != "xxend"
+then
+ exit 0
+fi

if test "x$1" = xstart && \
test -d /proc/xen && \
diff -r efa8d417e1a0 -r 6e53bd71bfb2 tools/hotplug/Linux/init.d/xendomains
--- a/tools/hotplug/Linux/init.d/xendomains Mon Jun 07 06:56:04 2010 +0100
+++ b/tools/hotplug/Linux/init.d/xendomains Mon Jun 07 07:05:54 2010 +0100
@@ -27,6 +27,13 @@
# Description: Start / stop domains automatically when domain 0
# boots / shuts down.
### END INIT INFO
+
+test -f /etc/sysconfig/xen_toolstack && . /etc/sysconfig/xen_toolstack
+
+if test "x$xen_toolstack" != "xxend"
+then
+ exit 0
+fi

# Correct exit code would probably be 5, but it's enough
# if xend complains if we're not running as privileged domain
diff -r efa8d417e1a0 -r 6e53bd71bfb2 tools/hotplug/Linux/xl-vif-script
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/Linux/xl-vif-script Mon Jun 07 07:05:54 2010 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+test -f /etc/sysconfig/xenlightdaemons && . /etc/sysconfig/xenlightdaemons
+
+if test "$VIF_SCRIPT"
+then
+ if test -f "$VIF_SCRIPT"
+ then
+ "$VIF_SCRIPT" $*
+ else
+ "$XEN_SCRIPTS_DIR"/"$VIF_SCRIPT" $*
+ fi
+fi
+
diff -r efa8d417e1a0 -r 6e53bd71bfb2 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Mon Jun 07 06:56:04 2010 +0100
+++ b/tools/libxl/libxl.h Mon Jun 07 07:05:54 2010 +0100
@@ -538,5 +538,17 @@ int libxl_tmem_set(struct libxl_ctx *ctx
uint32_t set);
int libxl_tmem_shared_auth(struct libxl_ctx *ctx, uint32_t domid, char* uuid,
int auth);
+
+/* common paths */
+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 /* LIBXL_H */

diff -r efa8d417e1a0 -r 6e53bd71bfb2 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Mon Jun 07 06:56:04 2010 +0100
+++ b/tools/libxl/libxl_internal.h Mon Jun 07 07:05:54 2010 +0100
@@ -215,17 +215,6 @@ void libxl_log_child_exitstatus(struct l

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);
-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);
-
#define XL_LOG_DEBUG XTL_DEBUG
#define XL_LOG_INFO XTL_INFO
#define XL_LOG_WARNING XTL_WARN
diff -r efa8d417e1a0 -r 6e53bd71bfb2 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Mon Jun 07 06:56:04 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Mon Jun 07 07:05:54 2010 +0100
@@ -41,6 +41,25 @@
#include "xl.h"

#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
+
+#define CHK_ERRNO( call ) ({ \
+ int chk_errno = (call); \
+ if (chk_errno < 0) { \
+ fprintf(stderr,"xl: fatal error: %s:%d: %s: %s\n", \
+ __FILE__,__LINE__, strerror(chk_errno), #call); \
+ exit(-ERROR_FAIL); \
+ } \
+ })
+
+#define MUST( call ) ({ \
+ int must_rc = (call); \
+ if (must_rc < 0) { \
+ fprintf(stderr,"xl: fatal error: %s:%d, rc=%d: %s\n", \
+ __FILE__,__LINE__, must_rc, #call); \
+ exit(-must_rc); \
+ } \
+ })
+

int logfile = 2;

@@ -240,7 +259,8 @@ static void init_nic_info(libxl_device_n
nic_info->mac[5] = 1 + (int) (0xff * (rand() / (RAND_MAX + 1.0)));
nic_info->ifname = NULL;
nic_info->bridge = "xenbr0";
- nic_info->script = "/etc/xen/scripts/vif-bridge";
+ CHK_ERRNO( asprintf(&nic_info->script, "%s/xl-vif-script",
+ libxl_xen_script_dir_path()) );
nic_info->nictype = NICTYPE_IOEMU;
}

@@ -791,24 +811,6 @@ skip_pci:
xlu_cfg_destroy(config);
}

-#define CHK_ERRNO( call ) ({ \
- int chk_errno = (call); \
- if (chk_errno) { \
- fprintf(stderr,"xl: fatal error: %s:%d: %s: %s\n", \
- __FILE__,__LINE__, strerror(chk_errno), #call); \
- exit(-ERROR_FAIL); \
- } \
- })
-
-#define MUST( call ) ({ \
- int must_rc = (call); \
- if (must_rc) { \
- fprintf(stderr,"xl: fatal error: %s:%d, rc=%d: %s\n", \
- __FILE__,__LINE__, must_rc, #call); \
- exit(-must_rc); \
- } \
- })
-
static void *xmalloc(size_t sz) {
void *r;
r = malloc(sz);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog