Skip to contentSkip to conversation

add xl init scripts

PATCH In review Stefano Stabellini 4 participants 6 messages Jun 4, 2010 – Jun 5, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add xl init scripts

Hi all,
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.

---

tools/hotplug/Linux/Makefile +8 -0
diff -r 4ab68bf4c37e tools/hotplug/Linux/Makefile
@@ -7,10 +7,15 @@
 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_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:
tools/hotplug/Linux/init.d/sysconfig.xen_toolstack new file +1 -0
diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/sysconfig.xen_toolstack
@@ -0,0 +1,1 @@
+xen_toolstack=xend
tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons new file +15 -0
diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons
@@ -0,0 +1,15 @@
+# Log xenconsoled messages (cf xl dmesg)
+#XENCONSOLED_TRACE=[none|guest|hv|all]
+
+# Log xenstored messages
+#XENSTORED_TRACE=[yes|on|1]
+
+# Running xenstored on XENSTORED_ROOTDIR
+#XENSTORED_ROOTDIR=/var/lib/xenstored
+
+# xen scripts dir
+XEN_SCRIPTS_DIR="/etc/xen/scripts"
+
+# See xend-config.sxp for a detailed explanation of these scripts
+NETWORK_SCRIPT=network-bridge
+VIF_SCRIPT=vif-bridge
tools/hotplug/Linux/init.d/xend +6 -0
diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/xend
@@ -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 && \
tools/hotplug/Linux/init.d/xendomains +7 -0
diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/xendomains
@@ -28,6 +28,13 @@
 #                    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
tools/hotplug/Linux/init.d/xenlightdaemons new file +108 -0

108 lines not on this page · raw message

tools/hotplug/Linux/xl-vif-script new file +14 -0
diff -r 4ab68bf4c37e tools/hotplug/Linux/xl-vif-script
@@ -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
+
tools/libxl/libxl.h +12 -0
diff -r 4ab68bf4c37e tools/libxl/libxl.h
@@ -536,5 +536,17 @@
                    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 */
 
tools/libxl/libxl_internal.h +0 -11
diff -r 4ab68bf4c37e tools/libxl/libxl_internal.h
@@ -215,17 +215,6 @@
 
 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
tools/libxl/xl_cmdimpl.c +21 -19
diff -r 4ab68bf4c37e tools/libxl/xl_cmdimpl.c
@@ -42,6 +42,25 @@
 
 #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 */
@@ -237,7 +256,8 @@
     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;
 }
 
@@ -784,24 +804,6 @@
     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);
#1 lore raw

Stefano Stabellini writes ("[Xen-devel] [PATCH] add xl init scripts"):

Quoted 2 lines

Please note that a correct value of xen_toolstack (either xl or xend), is required now.

Perhaps it would be better to set a default in each of the scripts which use it.

Ian.

#2 lore raw
In reply to Stefano Stabellini
Quoted 2 lines · Stefano Stabellini

The network script and the vif script to be used with xl can be specified in /etc/sysconfig/xenlightdaemons.

Would it be better to create /etc/init.d/{xenstored,xenconsoled} and /etc/sysconfig/{xenstored,xenconsoled} and have those used consistently no matter which toolstack was in use? Or maybe a single xendaemons script+config would do. In either case /etc/init.d/xend could be run only on systems which want xend, similarly for /etc/init.d/xl (if such a thing is still necessary after my comments below).

Is a network script really required for xl? I think it would be more in keeping with how xl works to require that the distro configuration be setup correctly to create bridges etc e.g. correctly
setup /etc/network/interfaces under Debian
or /etc/sysconfig/network-scripts/ifcfg-* under RH derived distros etc.

Similarly I think xl should assume that the platform has been correctly configured with a vif hotplug script with the correct behaviour? It's not clear to me why tools/hotplug/Linux/xen-backend.rules needs to use a different scheme for vif devices to all the other backend types. The script there could be a symlink to one of several variants if necessary, there's no reason for it to be a config item in xl (or xend for that matter)

It seems like we are now replicating some of the worst bits of xend poking around behind the back of the distro config files in xl.

Ian.

Quoted 336 lines

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.

---

diff -r 4ab68bf4c37e tools/hotplug/Linux/Makefile

tools/hotplug/Linux/Makefile Fri Jun 04 12:15:36 2010 +0100 renamed from tools/hotplug/Linux/Makefile Thu Jun 03 07:30:54 2010 +0100 +8 -0
@@ -7,10 +7,15 @@
 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_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 4ab68bf4c37e tools/hotplug/Linux/init.d/sysconfig.xen_toolstack

tools/hotplug/Linux/init.d/sysconfig.xen_toolstack Fri Jun 04 12:15:36 2010 +0100 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +1 -0
@@ -0,0 +1,1 @@
+xen_toolstack=xend

diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons

tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons Fri Jun 04 12:15:36 2010 +0100 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +15 -0
@@ -0,0 +1,15 @@
+# Log xenconsoled messages (cf xl dmesg)
+#XENCONSOLED_TRACE=[none|guest|hv|all]
+
+# Log xenstored messages
+#XENSTORED_TRACE=[yes|on|1]
+
+# Running xenstored on XENSTORED_ROOTDIR
+#XENSTORED_ROOTDIR=/var/lib/xenstored
+
+# xen scripts dir
+XEN_SCRIPTS_DIR="/etc/xen/scripts"
+
+# See xend-config.sxp for a detailed explanation of these scripts
+NETWORK_SCRIPT=network-bridge
+VIF_SCRIPT=vif-bridge

diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/xend

tools/hotplug/Linux/init.d/xend Fri Jun 04 12:15:36 2010 +0100 renamed from tools/hotplug/Linux/init.d/xend Thu Jun 03 07:30:54 2010 +0100 +6 -0
@@ -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 4ab68bf4c37e tools/hotplug/Linux/init.d/xendomains

tools/hotplug/Linux/init.d/xendomains Fri Jun 04 12:15:36 2010 +0100 renamed from tools/hotplug/Linux/init.d/xendomains Thu Jun 03 07:30:54 2010 +0100 +7 -0
@@ -28,6 +28,13 @@
 #                    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 -r 4ab68bf4c37e tools/hotplug/Linux/init.d/xenlightdaemons

tools/hotplug/Linux/init.d/xenlightdaemons Fri Jun 04 12:15:36 2010 +0100 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +108 -0
@@ -0,0 +1,108 @@
+#!/bin/bash
+#
+# xenlightdaemons    Script to start and stop xenstored and xenconsoled
+#                    FOR USE WITH LIBXL, not xend
+#
+# Author:       Ian Jackson <[email protected]>
+#
+# chkconfig: 2345
+# description: Starts and stops the Xen control daemon.
+### BEGIN INIT INFO
+# Provides:          xenstored xenconsoled
+# Required-Start:    $syslog $remote_fs
+# Should-Start:
+# Required-Stop:     $syslog $remote_fs
+# Should-Stop:
+# Default-Start:     3 4 5
+# Default-Stop:      1
+# Default-Enabled:   yes
+# Short-Description: Start/stop xenstored and xenconsoled
+# Description:       Starts and stops the daemons neeeded for xl/libxenlight
+### END INIT INFO
+
+test -f /etc/sysconfig/xen_toolstack && . /etc/sysconfig/xen_toolstack
+
+if test "x$xen_toolstack" != "xxl"
+then
+    exit 0
+fi
+
+test -f /etc/sysconfig/xenlightdaemons && . /etc/sysconfig/xenlightdaemons
+
+XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
+shopt -s extglob
+
+if test "x$1" = xstart && \
+     test -d /proc/xen && \
+   ! test -d /proc/xen/capabilities && \
+     grep '    xenfs$' /proc/filesystems >/dev/null && \
+   ! grep '^xenfs ' /proc/mounts >/dev/null;
+then
+       mount -t xenfs xenfs /proc/xen
+fi
+
+if ! grep -q "control_d" /proc/xen/capabilities ; then
+       exit 0
+fi
+
+do_start () {
+       test -z "$XENSTORED_ROOTDIR" || export XENSTORED_ROOTDIR
+       [[ "$XENSTORED_TRACE" == @(yes|on|1) ]] && export XENSTORED_TRACE
+       xenstore-read -s / >/dev/null 2>&1 || xenstored
+       xenstore-write "/local/domain/0/name" "Domain-0"
+
+       test -z "$XENCONSOLED_TRACE" || export XENCONSOLED_TRACE
+       xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_OPTIONS
+
+       if test "$NETWORK_SCRIPT"
+       then
+               if test -f "$NETWORK_SCRIPT"
+               then
+                       "$NETWORK_SCRIPT" start
+               else
+                       "$XEN_SCRIPTS_DIR"/"$NETWORK_SCRIPT" start
+               fi
+       fi
+}
+do_stop () {
+       if read 2>/dev/null <$XENCONSOLED_PIDFILE pid; then
+               kill $pid
+               while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
+               rm -f $XENCONSOLED_PIDFILE
+       fi
+       if test "$NETWORK_SCRIPT"
+       then
+               if test -f "$NETWORK_SCRIPT"
+               then
+                       "$NETWORK_SCRIPT" stop
+               else
+                       "$XEN_SCRIPTS_DIR"/"$NETWORK_SCRIPT" stop
+               fi
+       fi
+}
+
+case "$1" in
+  start)
+       do_start
+       ;;
+  status)
+        xenstore-read -s /
+       ;;
+  stop)
+       do_stop
+       ;;
+  reload)
+       echo >&2 'Reload not available; use force-reload'; exit 1
+       ;;
+  force-reload|restart)
+        do_stop
+       do_start
+       ;;
+  *)
+       # do not advertise unreasonable commands that there is no reason
+       # to use with this device
+       echo $"Usage: $0 {start|stop|status|restart|force-reload}"
+       exit 1
+esac
+
+exit $?

diff -r 4ab68bf4c37e tools/hotplug/Linux/xl-vif-script

tools/hotplug/Linux/xl-vif-script Fri Jun 04 12:15:36 2010 +0100 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +14 -0
@@ -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 4ab68bf4c37e tools/libxl/libxl.h

tools/libxl/libxl.h Fri Jun 04 12:15:36 2010 +0100 renamed from tools/libxl/libxl.h Thu Jun 03 07:30:54 2010 +0100 +12 -0
@@ -536,5 +536,17 @@
                    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 4ab68bf4c37e tools/libxl/libxl_internal.h

tools/libxl/libxl_internal.h Fri Jun 04 12:15:36 2010 +0100 renamed from tools/libxl/libxl_internal.h Thu Jun 03 07:30:54 2010 +0100 +0 -11
@@ -215,17 +215,6 @@
 
 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 4ab68bf4c37e tools/libxl/xl_cmdimpl.c

tools/libxl/xl_cmdimpl.c Fri Jun 04 12:15:36 2010 +0100 renamed from tools/libxl/xl_cmdimpl.c Thu Jun 03 07:30:54 2010 +0100 +21 -19
@@ -42,6 +42,25 @@
 
 #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 */
@@ -237,7 +256,8 @@
     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;
 }
 
@@ -784,24 +804,6 @@
     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-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Stefano Stabellini

The network script and the vif script to be used with xl can be specified in /etc/sysconfig/xenlightdaemons.

Would it be better to create /etc/init.d/{xenstored,xenconsoled} and /etc/sysconfig/{xenstored,xenconsoled} and have those used consistently no matter which toolstack was in use?

There are several small daemons on a xen installation and the number of them is growing quickly.
Having a separate init script for each of them might not be a winning strategy in the medium/long term.

Quoted 5 lines

Or maybe a single
xendaemons script+config would do. In either case /etc/init.d/xend could be run only on systems which want xend, similarly for /etc/init.d/xl (if such a thing is still necessary after my comments below).

This is exactly the idea, the variable in xen_toolstack is only to make sure that we don't break anything if both toolstacks and scripts are installed.

Quoted 14 lines

Is a network script really required for xl? I think it would be more in keeping with how xl works to require that the distro configuration be setup correctly to create bridges etc e.g. correctly
setup /etc/network/interfaces under Debian
or /etc/sysconfig/network-scripts/ifcfg-* under RH derived distros etc.

Similarly I think xl should assume that the platform has been correctly configured with a vif hotplug script with the correct behaviour? It's not clear to me why tools/hotplug/Linux/xen-backend.rules needs to use a different scheme for vif devices to all the other backend types. The script there could be a symlink to one of several variants if necessary, there's no reason for it to be a config item in xl (or xend for that matter)

Quoted 3 lines

It seems like we are now replicating some of the worst bits of xend poking around behind the back of the distro config files in xl.

I think using the distro settings is definitely better, in fact you can set whatever network script you want (including nothing), in the NETWORK_SCRIPT variable, maybe NETWORK_SCRIPT= could be the default.

However network-bridge is quite handy and simple to use, I think we should provide the users a simple way to automatically setup the network no matter what their distro is.

#4 lore raw
Quoted 18 lines · Stefano Stabellini
Quoted 14 lines

Is a network script really required for xl? I think it would be more in keeping with how xl works to require that the distro configuration be setup correctly to create bridges etc e.g. correctly
setup /etc/network/interfaces under Debian
or /etc/sysconfig/network-scripts/ifcfg-* under RH derived distros etc.

Similarly I think xl should assume that the platform has been correctly configured with a vif hotplug script with the correct behaviour? It's not clear to me why tools/hotplug/Linux/xen-backend.rules needs to use a different scheme for vif devices to all the other backend types. The script there could be a symlink to one of several variants if necessary, there's no reason for it to be a config item in xl (or xend for that matter)

Quoted 3 lines

It seems like we are now replicating some of the worst bits of xend poking around behind the back of the distro config files in xl.

Quoted 8 lines

I think using the distro settings is definitely better, in fact you can set whatever network script you want (including nothing), in the NETWORK_SCRIPT variable, maybe NETWORK_SCRIPT= could be the default.

However network-bridge is quite handy and simple to use, I think we should provide the users a simple way to automatically setup the network no matter what their distro is.

Expanding on the xen-backend.rules subject, I guess the advantage of the current strategy is that it allows users to configure each vif of each VM differently, whether they want them in routed or bridged mode or even other possible configurations we don't know about. If we hardcode the script name in xen-backend.rules then it would become a global platform configuration and not a per-vif configuration anymore.
If we decide that we don't care about it, then we can use a symlink or a simple script that changes behavior depending on a sysconfig variable, like you said.

#5 lore raw
In reply to Ian Campbell
Quoted 7 lines · Ian Campbell

Would it be better to create /etc/init.d/{xenstored,xenconsoled} and /etc/sysconfig/{xenstored,xenconsoled} and have those used consistently no matter which toolstack was in use? Or maybe a single xendaemons script+config would do. In either case /etc/init.d/xend could be run only on systems which want xend, similarly for /etc/init.d/xl (if such a thing is still necessary after my comments below).

Perhaps. xl doesn't need any setup per-se, except for "xl rename 0 Domain-0" to avoid an ugly (null).

Quoted 6 lines

Is a network script really required for xl? I think it would be more in keeping with how xl works to require that the distro configuration be setup correctly to create bridges etc e.g. correctly
setup /etc/network/interfaces under Debian
or /etc/sysconfig/network-scripts/ifcfg-* under RH derived distros etc.

Yes, yes, yes. Its easy to get Redhat/Fedora to set up a bridge as part of its normal network setup. There's no need for us to duplicate it.

Quoted 11 lines

Similarly I think xl should assume that the platform has been correctly configured with a vif hotplug script with the correct behaviour? It's not clear to me why tools/hotplug/Linux/xen-backend.rules needs to use a different scheme for vif devices to all the other backend types. The script there could be a symlink to one of several variants if necessary, there's no reason for it to be a config item in xl (or xend for that matter)

It seems like we are now replicating some of the worst bits of xend poking around behind the back of the distro config files in xl.

Agree, unless as Stefano mentions, there's a need for some kind of per-domain network setup (bridges, vlans, firewall rules, etc?).

J