]> xenbits.xensource.com Git - xen.git/commitdiff
Add xl init scripts
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 7 Jun 2010 06:05:54 +0000 (07:05 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 7 Jun 2010 06:05:54 +0000 (07:05 +0100)
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
tools/hotplug/Linux/init.d/xend
tools/hotplug/Linux/init.d/xendomains
tools/hotplug/Linux/xl-vif-script [new file with mode: 0644]
tools/libxl/libxl.h
tools/libxl/libxl_internal.h
tools/libxl/xl_cmdimpl.c

index fa9e2b5c45dbb967a5599013cbe2edccdb8dddee..ffb3d74b823127af65678a8ca7c09d9c10e6ade0 100644 (file)
@@ -7,10 +7,15 @@ XEND_SYSCONFIG = init.d/sysconfig.xend
 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:
index 40160047900fe738500171d632d6f7b88e212612..6273a408320db1a1ce6a260596541f5fa3d4ab7d 100755 (executable)
 
 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 && \
index 70b5b8fdcf01940cff691f5b0ec04ca19c278e8b..84a16dc1e8c5b4bde8d1c41f166e90afab44bc63 100644 (file)
 #                    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
 if ! [ -e /proc/xen/privcmd ]; then
diff --git a/tools/hotplug/Linux/xl-vif-script b/tools/hotplug/Linux/xl-vif-script
new file mode 100644 (file)
index 0000000..ec53c55
--- /dev/null
@@ -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
+
index b5d972c529ab265cde7b826c044ec6491aecae82..490b7570f76f8fcb512fc6704ed7bfe2b211d033 100644 (file)
@@ -538,5 +538,17 @@ int libxl_tmem_set(struct libxl_ctx *ctx, uint32_t domid, char* name,
                    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 */
 
index f45d0d539c37f4a067fbec8195dfbe5fefb1d05a..5767ae2cf2d03fbc8dd8ebef444208a098e0c955 100644 (file)
@@ -215,17 +215,6 @@ void libxl_log_child_exitstatus(struct libxl_ctx *ctx,
 
 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
index dbdfb83c0584499f5f9a81d3a4ffc74b045bfd3e..2633a64b652da2f8ee303dcee8479e2b4b02393d 100644 (file)
 
 #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;
 
 /* every libxl action in xl uses this same libxl context */
@@ -240,7 +259,8 @@ static void init_nic_info(libxl_device_nic *nic_info, int devnum)
     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);