WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] add xl init scripts

To: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] add xl init scripts
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Fri, 4 Jun 2010 16:26:54 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 04 Jun 2010 08:27:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <alpine.DEB.2.00.1006041215390.3401@kaball-desktop>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <alpine.DEB.2.00.1006041215390.3401@kaball-desktop>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxx>
> 
> ---
> 
> 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@xxxxxxxxxxxxx>
> +#
> +# 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@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



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

<Prev in Thread] Current Thread [Next in Thread>