* [PATCH] add xl init scripts
@ 2010-06-04 11:37 Stefano Stabellini
2010-06-04 15:14 ` Ian Jackson
2010-06-04 15:26 ` Ian Campbell
0 siblings, 2 replies; 6+ messages in thread
From: Stefano Stabellini @ 2010-06-04 11:37 UTC (permalink / raw)
To: xen-devel
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.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
diff -r 4ab68bf4c37e tools/hotplug/Linux/Makefile
--- a/tools/hotplug/Linux/Makefile Thu Jun 03 07:30:54 2010 +0100
+++ b/tools/hotplug/Linux/Makefile Fri Jun 04 12:15:36 2010 +0100
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/Linux/init.d/sysconfig.xen_toolstack Fri Jun 04 12:15:36 2010 +0100
@@ -0,0 +1,1 @@
+xen_toolstack=xend
diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons Fri Jun 04 12:15:36 2010 +0100
@@ -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
--- a/tools/hotplug/Linux/init.d/xend Thu Jun 03 07:30:54 2010 +0100
+++ b/tools/hotplug/Linux/init.d/xend Fri Jun 04 12:15:36 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 4ab68bf4c37e tools/hotplug/Linux/init.d/xendomains
--- a/tools/hotplug/Linux/init.d/xendomains Thu Jun 03 07:30:54 2010 +0100
+++ b/tools/hotplug/Linux/init.d/xendomains Fri Jun 04 12:15:36 2010 +0100
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/Linux/init.d/xenlightdaemons Fri Jun 04 12:15:36 2010 +0100
@@ -0,0 +1,108 @@
+#!/bin/bash
+#
+# xenlightdaemons Script to start and stop xenstored and xenconsoled
+# FOR USE WITH LIBXL, not xend
+#
+# Author: Ian Jackson <ian.jackson@eu.citrix.com>
+#
+# 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/hotplug/Linux/xl-vif-script Fri Jun 04 12:15:36 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 4ab68bf4c37e tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Thu Jun 03 07:30:54 2010 +0100
+++ b/tools/libxl/libxl.h Fri Jun 04 12:15:36 2010 +0100
@@ -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
--- a/tools/libxl/libxl_internal.h Thu Jun 03 07:30:54 2010 +0100
+++ b/tools/libxl/libxl_internal.h Fri Jun 04 12:15:36 2010 +0100
@@ -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
--- a/tools/libxl/xl_cmdimpl.c Thu Jun 03 07:30:54 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Fri Jun 04 12:15:36 2010 +0100
@@ -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);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add xl init scripts
2010-06-04 11:37 [PATCH] add xl init scripts Stefano Stabellini
@ 2010-06-04 15:14 ` Ian Jackson
2010-06-04 15:26 ` Ian Campbell
1 sibling, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2010-06-04 15:14 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: xen-devel
Stefano Stabellini writes ("[Xen-devel] [PATCH] add xl init scripts"):
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add xl init scripts
2010-06-04 11:37 [PATCH] add xl init scripts Stefano Stabellini
2010-06-04 15:14 ` Ian Jackson
@ 2010-06-04 15:26 ` Ian Campbell
2010-06-04 16:22 ` Stefano Stabellini
2010-06-05 0:12 ` Jeremy Fitzhardinge
1 sibling, 2 replies; 6+ messages in thread
From: Ian Campbell @ 2010-06-04 15:26 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: xen-devel@lists.xensource.com
On Fri, 2010-06-04 at 12:37 +0100, Stefano Stabellini wrote:
> 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.
> 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>
>
> ---
>
> diff -r 4ab68bf4c37e tools/hotplug/Linux/Makefile
> --- a/tools/hotplug/Linux/Makefile Thu Jun 03 07:30:54 2010 +0100
> +++ b/tools/hotplug/Linux/Makefile Fri Jun 04 12:15:36 2010 +0100
> @@ -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
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/hotplug/Linux/init.d/sysconfig.xen_toolstack Fri Jun 04 12:15:36 2010 +0100
> @@ -0,0 +1,1 @@
> +xen_toolstack=xend
> diff -r 4ab68bf4c37e tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/hotplug/Linux/init.d/sysconfig.xenlightdaemons Fri Jun 04 12:15:36 2010 +0100
> @@ -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
> --- a/tools/hotplug/Linux/init.d/xend Thu Jun 03 07:30:54 2010 +0100
> +++ b/tools/hotplug/Linux/init.d/xend Fri Jun 04 12:15:36 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 4ab68bf4c37e tools/hotplug/Linux/init.d/xendomains
> --- a/tools/hotplug/Linux/init.d/xendomains Thu Jun 03 07:30:54 2010 +0100
> +++ b/tools/hotplug/Linux/init.d/xendomains Fri Jun 04 12:15:36 2010 +0100
> @@ -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
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/hotplug/Linux/init.d/xenlightdaemons Fri Jun 04 12:15:36 2010 +0100
> @@ -0,0 +1,108 @@
> +#!/bin/bash
> +#
> +# xenlightdaemons Script to start and stop xenstored and xenconsoled
> +# FOR USE WITH LIBXL, not xend
> +#
> +# Author: Ian Jackson <ian.jackson@eu.citrix.com>
> +#
> +# 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
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/hotplug/Linux/xl-vif-script Fri Jun 04 12:15:36 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 4ab68bf4c37e tools/libxl/libxl.h
> --- a/tools/libxl/libxl.h Thu Jun 03 07:30:54 2010 +0100
> +++ b/tools/libxl/libxl.h Fri Jun 04 12:15:36 2010 +0100
> @@ -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
> --- a/tools/libxl/libxl_internal.h Thu Jun 03 07:30:54 2010 +0100
> +++ b/tools/libxl/libxl_internal.h Fri Jun 04 12:15:36 2010 +0100
> @@ -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
> --- a/tools/libxl/xl_cmdimpl.c Thu Jun 03 07:30:54 2010 +0100
> +++ b/tools/libxl/xl_cmdimpl.c Fri Jun 04 12:15:36 2010 +0100
> @@ -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
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add xl init scripts
2010-06-04 15:26 ` Ian Campbell
@ 2010-06-04 16:22 ` Stefano Stabellini
2010-06-04 16:55 ` Stefano Stabellini
2010-06-05 0:12 ` Jeremy Fitzhardinge
1 sibling, 1 reply; 6+ messages in thread
From: Stefano Stabellini @ 2010-06-04 16:22 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Stefano Stabellini
On Fri, 4 Jun 2010, Ian Campbell wrote:
> On Fri, 2010-06-04 at 12:37 +0100, Stefano Stabellini wrote:
> > 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.
> 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.
> 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.
>
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add xl init scripts
2010-06-04 16:22 ` Stefano Stabellini
@ 2010-06-04 16:55 ` Stefano Stabellini
0 siblings, 0 replies; 6+ messages in thread
From: Stefano Stabellini @ 2010-06-04 16:55 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: Ian Campbell, xen-devel@lists.xensource.com
On Fri, 4 Jun 2010, Stefano Stabellini wrote:
> > 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.
> >
>
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] add xl init scripts
2010-06-04 15:26 ` Ian Campbell
2010-06-04 16:22 ` Stefano Stabellini
@ 2010-06-05 0:12 ` Jeremy Fitzhardinge
1 sibling, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2010-06-05 0:12 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Stefano Stabellini
On 06/04/2010 08:26 AM, Ian Campbell wrote:
> 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).
> 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.
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-06-05 0:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-04 11:37 [PATCH] add xl init scripts Stefano Stabellini
2010-06-04 15:14 ` Ian Jackson
2010-06-04 15:26 ` Ian Campbell
2010-06-04 16:22 ` Stefano Stabellini
2010-06-04 16:55 ` Stefano Stabellini
2010-06-05 0:12 ` Jeremy Fitzhardinge
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.