[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xencommons: move module list into a generic place



commit fafbc2926c3ef2c9270fc765a4b3c36d868651a5
Author:     Luis R. Rodriguez <mcgrof@xxxxxxxx>
AuthorDate: Wed Jul 30 09:40:01 2014 -0700
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Mon Aug 4 14:58:23 2014 +0100

    xencommons: move module list into a generic place
    
    This will allow us to share the same module list with
    systemd, and lets us upkeep it in one place. Document this
    while at it on the top level README and expand on the wiki:
    
    http://wiki.xen.org/wiki/Category:Host_Configuration#Kernel_modules
    
    In order to upkeep parallelism builds be explicit about the
    requirement to complete all actions before any installation
    targets.
    
    Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 README                                   |   12 ++
 config/Linux.modules                     |   20 ++++
 tools/hotplug/Linux/Makefile             |   14 ++-
 tools/hotplug/Linux/init.d/xencommons    |  167 ------------------------------
 tools/hotplug/Linux/init.d/xencommons.in |  153 +++++++++++++++++++++++++++
 tools/hotplug/Linux/update-modules.sh    |   36 +++++++
 6 files changed, 231 insertions(+), 171 deletions(-)

diff --git a/README b/README
index 9bbe734..0c8c7aa 100644
--- a/README
+++ b/README
@@ -183,3 +183,15 @@ There are optional targets as part of Xen's top-level 
makefile that will
 download and build tboot: install-tboot, build-tboot, dist-tboot, clean-tboot.
 These will download the latest tar file from the SourceForge site using wget,
 then build/install/dist according to Xen's settings.
+
+Required Kernel modules
+======================
+
+Xen has a set of Kernel modules which the init scripts ensure to load before
+before starting Xen guests. The list of modules are maintained in one place:
+
+  * config/$(XEN_OS).modules
+
+For more details refer to:
+
+http://wiki.xen.org/wiki/Category:Host_Configuration#Kernel_modules
diff --git a/config/Linux.modules b/config/Linux.modules
new file mode 100644
index 0000000..8a764df
--- /dev/null
+++ b/config/Linux.modules
@@ -0,0 +1,20 @@
+# The file supports a simple language, comments are ignored, and if you there
+# are module replacements this can be listed by using a pipe to show preference
+# for the first module, followed by the older module.
+
+xen-evtchn
+xen-gntdev
+xen-gntalloc
+xen-blkback
+xen-netback
+xen-pciback
+evtchn
+gntdev
+netbk
+blkbk
+xen-scsibk
+usbbk
+pciback
+xen-acpi-processor
+# Prefer to load blktap2 if found, otherwise load blktap
+blktap2|blktap
diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile
index d5de9e6..3d2d344 100644
--- a/tools/hotplug/Linux/Makefile
+++ b/tools/hotplug/Linux/Makefile
@@ -33,17 +33,23 @@ UDEV_RULES_DIR = $(CONFIG_DIR)/udev
 UDEV_RULES = xen-backend.rules $(UDEV_RULES-y)
 
 .PHONY: all
-all:
+all: $(XENCOMMONS_INITD)
+
+$(XENCOMMONS_INITD): $(XEN_ROOT)/config/$(XEN_OS).modules 
$(XENCOMMONS_INITD).in
+       $(XEN_ROOT)/tools/hotplug/Linux/update-modules.sh \
+               $(XEN_ROOT) \
+               $(XEN_OS) \
+               $(XENCOMMONS_INITD) > $@
 
 .PHONY: build
-build:
+build: all
 
 .PHONY: install
 install: all install-initd install-scripts install-udev
 
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
-install-initd:
+install-initd: all
        [ -d $(DESTDIR)$(INITD_DIR) ] || $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
        [ -d $(DESTDIR)$(SYSCONFIG_DIR) ] || $(INSTALL_DIR) 
$(DESTDIR)$(SYSCONFIG_DIR)
        [ -d $(DESTDIR)$(LIBEXEC) ] || $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)
@@ -55,7 +61,7 @@ install-initd:
        $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
 .PHONY: install-scripts
-install-scripts:
+install-scripts: all
        [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
                $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
        set -e; for i in $(XEN_SCRIPTS); \
diff --git a/tools/hotplug/Linux/init.d/xencommons 
b/tools/hotplug/Linux/init.d/xencommons
deleted file mode 100644
index 4ebd636..0000000
--- a/tools/hotplug/Linux/init.d/xencommons
+++ /dev/null
@@ -1,167 +0,0 @@
-#!/bin/bash
-#
-# xencommons    Script to start and stop xenstored and xenconsoled
-#
-# Author:       Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
-#
-# chkconfig: 2345 70 10
-# description: Starts and stops xenstored and xenconsoled
-### BEGIN INIT INFO
-# Provides:          xenstored xenconsoled
-# Required-Start:    $syslog $remote_fs
-# Should-Start:
-# Required-Stop:     $syslog $remote_fs
-# Should-Stop:
-# Default-Start:     2 3 5
-# Default-Stop:      0 1 6
-# Short-Description: Start/stop xenstored and xenconsoled
-# Description:       Starts and stops the daemons neeeded for xl/xend
-### END INIT INFO
-
-. /etc/xen/scripts/hotplugpath.sh
-
-if [ -d /etc/sysconfig ]; then
-       xencommons_config=/etc/sysconfig
-else
-       xencommons_config=/etc/default
-fi
-
-test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
-
-XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
-QEMU_PIDFILE=/var/run/qemu-dom0.pid
-shopt -s extglob
-
-# not running in Xen dom0 or domU
-if ! test -d /proc/xen ; then
-       exit 0
-fi
-
-# mount xenfs in dom0 or domU with a pv_ops kernel
-if test "x$1" = xstart && \
-   ! test -f /proc/xen/capabilities && \
-   ! grep '^xenfs ' /proc/mounts >/dev/null;
-then
-       mount -t xenfs xenfs /proc/xen
-fi
-
-# run this script only in dom0:
-# no capabilities file in xenlinux domU kernel
-# empty capabilities file in pv_ops domU kernel
-if test -f /proc/xen/capabilities && \
-   ! grep -q "control_d" /proc/xen/capabilities ; then
-       exit 0
-fi
-
-do_start () {
-        local time=0
-       local timeout=30
-
-       modprobe xen-evtchn 2>/dev/null
-       modprobe xen-gntdev 2>/dev/null
-       modprobe xen-gntalloc 2>/dev/null
-       modprobe xen-blkback 2>/dev/null
-       modprobe xen-netback 2>/dev/null
-       modprobe xen-pciback 2>/dev/null
-       modprobe evtchn 2>/dev/null
-       modprobe gntdev 2>/dev/null
-       modprobe netbk 2>/dev/null
-       modprobe blkbk 2>/dev/null
-       modprobe xen-scsibk 2>/dev/null
-       modprobe usbbk 2>/dev/null
-       modprobe pciback 2>/dev/null
-       modprobe xen-acpi-processor 2>/dev/null
-       modprobe blktap2 2>/dev/null || modprobe blktap 2>/dev/null
-       mkdir -p /var/run/xen
-
-       if ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1`
-       then
-               test -z "$XENSTORED_ROOTDIR" && 
XENSTORED_ROOTDIR="/var/lib/xenstored"
-               rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
-               test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T 
/var/log/xen/xenstored-trace.log"
-
-               if [ -n "$XENSTORED" ] ; then
-                   echo -n Starting $XENSTORED...
-                   $XENSTORED --pid-file /var/run/xenstored.pid $XENSTORED_ARGS
-               elif [ -x ${SBINDIR}/oxenstored ] ; then
-                   echo -n Starting oxenstored...
-                   ${SBINDIR}/oxenstored --pid-file /var/run/xenstored.pid 
$XENSTORED_ARGS
-               elif [ -x ${SBINDIR}/xenstored ] ; then
-                   echo -n Starting C xenstored...
-                   ${SBINDIR}/xenstored --pid-file /var/run/xenstored.pid 
$XENSTORED_ARGS
-               else
-                   echo "No xenstored found"
-                   exit 1
-               fi
-
-               # Wait for xenstored to actually come up, timing out after 30 
seconds
-                while [ $time -lt $timeout ] && ! `${BINDIR}/xenstore-read -s 
/ >/dev/null 2>&1` ; do
-                    echo -n .
-                   time=$(($time+1))
-                    sleep 1
-                done
-               echo
-
-               # Exit if we timed out
-               if ! [ $time -lt $timeout ] ; then
-                   echo Could not start xenstored
-                   exit 1
-               fi
-
-               echo Setting domain 0 name and domid...
-               ${BINDIR}/xenstore-write "/local/domain/0/name" "Domain-0"
-               ${BINDIR}/xenstore-write "/local/domain/0/domid" 0
-       fi
-
-       echo Starting xenconsoled...
-       test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" 
--log=$XENCONSOLED_TRACE"
-       ${SBINDIR}/xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS
-       echo Starting QEMU as disk backend for dom0
-       test -z "$QEMU_XEN" && QEMU_XEN="${LIBEXEC}/qemu-system-i386"
-       $QEMU_XEN -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv 
-daemonize \
-               -monitor /dev/null -serial /dev/null -parallel /dev/null \
-               -pidfile $QEMU_PIDFILE
-}
-do_stop () {
-        echo Stopping xenconsoled
-       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
-
-       echo Stopping QEMU
-       if read 2>/dev/null <$QEMU_PIDFILE pid; then
-               kill $pid
-               while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
-               rm -f $QEMU_PIDFILE
-       fi
-
-       echo WARNING: Not stopping xenstored, as it cannot be restarted.
-}
-
-case "$1" in
-  start)
-       do_start
-       ;;
-  status)
-        ${BINDIR}/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 --git a/tools/hotplug/Linux/init.d/xencommons.in 
b/tools/hotplug/Linux/init.d/xencommons.in
new file mode 100644
index 0000000..3939bcc
--- /dev/null
+++ b/tools/hotplug/Linux/init.d/xencommons.in
@@ -0,0 +1,153 @@
+#!/bin/bash
+#
+# xencommons    Script to start and stop xenstored and xenconsoled
+#
+# Author:       Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
+#
+# chkconfig: 2345 70 10
+# description: Starts and stops xenstored and xenconsoled
+### BEGIN INIT INFO
+# Provides:          xenstored xenconsoled
+# Required-Start:    $syslog $remote_fs
+# Should-Start:
+# Required-Stop:     $syslog $remote_fs
+# Should-Stop:
+# Default-Start:     2 3 5
+# Default-Stop:      0 1 6
+# Short-Description: Start/stop xenstored and xenconsoled
+# Description:       Starts and stops the daemons neeeded for xl/xend
+### END INIT INFO
+
+. /etc/xen/scripts/hotplugpath.sh
+
+if [ -d /etc/sysconfig ]; then
+       xencommons_config=/etc/sysconfig
+else
+       xencommons_config=/etc/default
+fi
+
+test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
+
+XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
+QEMU_PIDFILE=/var/run/qemu-dom0.pid
+shopt -s extglob
+
+# not running in Xen dom0 or domU
+if ! test -d /proc/xen ; then
+       exit 0
+fi
+
+# mount xenfs in dom0 or domU with a pv_ops kernel
+if test "x$1" = xstart && \
+   ! test -f /proc/xen/capabilities && \
+   ! grep '^xenfs ' /proc/mounts >/dev/null;
+then
+       mount -t xenfs xenfs /proc/xen
+fi
+
+# run this script only in dom0:
+# no capabilities file in xenlinux domU kernel
+# empty capabilities file in pv_ops domU kernel
+if test -f /proc/xen/capabilities && \
+   ! grep -q "control_d" /proc/xen/capabilities ; then
+       exit 0
+fi
+
+do_start () {
+        local time=0
+       local timeout=30
+
+       @LOAD_MODULES@
+       mkdir -p /var/run/xen
+
+       if ! `${BINDIR}/xenstore-read -s / >/dev/null 2>&1`
+       then
+               test -z "$XENSTORED_ROOTDIR" && 
XENSTORED_ROOTDIR="/var/lib/xenstored"
+               rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
+               test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T 
/var/log/xen/xenstored-trace.log"
+
+               if [ -n "$XENSTORED" ] ; then
+                   echo -n Starting $XENSTORED...
+                   $XENSTORED --pid-file /var/run/xenstored.pid $XENSTORED_ARGS
+               elif [ -x ${SBINDIR}/oxenstored ] ; then
+                   echo -n Starting oxenstored...
+                   ${SBINDIR}/oxenstored --pid-file /var/run/xenstored.pid 
$XENSTORED_ARGS
+               elif [ -x ${SBINDIR}/xenstored ] ; then
+                   echo -n Starting C xenstored...
+                   ${SBINDIR}/xenstored --pid-file /var/run/xenstored.pid 
$XENSTORED_ARGS
+               else
+                   echo "No xenstored found"
+                   exit 1
+               fi
+
+               # Wait for xenstored to actually come up, timing out after 30 
seconds
+                while [ $time -lt $timeout ] && ! `${BINDIR}/xenstore-read -s 
/ >/dev/null 2>&1` ; do
+                    echo -n .
+                   time=$(($time+1))
+                    sleep 1
+                done
+               echo
+
+               # Exit if we timed out
+               if ! [ $time -lt $timeout ] ; then
+                   echo Could not start xenstored
+                   exit 1
+               fi
+
+               echo Setting domain 0 name and domid...
+               ${BINDIR}/xenstore-write "/local/domain/0/name" "Domain-0"
+               ${BINDIR}/xenstore-write "/local/domain/0/domid" 0
+       fi
+
+       echo Starting xenconsoled...
+       test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" 
--log=$XENCONSOLED_TRACE"
+       ${SBINDIR}/xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS
+       echo Starting QEMU as disk backend for dom0
+       test -z "$QEMU_XEN" && QEMU_XEN="${LIBEXEC}/qemu-system-i386"
+       $QEMU_XEN -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv 
-daemonize \
+               -monitor /dev/null -serial /dev/null -parallel /dev/null \
+               -pidfile $QEMU_PIDFILE
+}
+do_stop () {
+        echo Stopping xenconsoled
+       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
+
+       echo Stopping QEMU
+       if read 2>/dev/null <$QEMU_PIDFILE pid; then
+               kill $pid
+               while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
+               rm -f $QEMU_PIDFILE
+       fi
+
+       echo WARNING: Not stopping xenstored, as it cannot be restarted.
+}
+
+case "$1" in
+  start)
+       do_start
+       ;;
+  status)
+        ${BINDIR}/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 --git a/tools/hotplug/Linux/update-modules.sh 
b/tools/hotplug/Linux/update-modules.sh
new file mode 100755
index 0000000..692d220
--- /dev/null
+++ b/tools/hotplug/Linux/update-modules.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+set -e
+
+IFS=''
+
+XEN_ROOT=$1
+XEN_OS=$2
+XENCOMMONS_INITD=$3
+
+cat  $XEN_ROOT/config/${XEN_OS}.modules        | (
+       while read l ; do
+               if echo $l | egrep -q "^#" ; then
+                       continue
+               fi
+               if echo "$l" | egrep -q "\|" ; then
+                       m1=${l%%|*}
+                       m2=${l#*|}
+                       echo "        modprobe $m1 2>/dev/null || modprobe $m2 
2>/dev/null"
+               else
+                       echo "        modprobe $l 2>/dev/null"
+               fi
+       done
+) > ${XENCOMMONS_INITD}.modules
+
+cat  ${XENCOMMONS_INITD}.in    | (
+       while read l ; do
+               if echo "$l" | egrep -q "@LOAD_MODULES@" ; then
+                       cat ${XENCOMMONS_INITD}.modules
+               else
+                       echo $l
+               fi
+       done
+)
+
+rm -f ${XENCOMMONS_INITD}.modules
--
generated by git-patchbot for /home/xen/git/xen.git#master

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.