All of lore.kernel.org
 help / color / mirror / Atom feed
* xendomains init script
@ 2005-10-19  9:44 Kurt Garloff
  2005-10-26 17:11 ` Ewan Mellor
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Kurt Garloff @ 2005-10-19  9:44 UTC (permalink / raw)
  To: Xen development list


[-- Attachment #1.1.1: Type: text/plain, Size: 708 bytes --]

Hi,

I worked on the xendomains init script.

It now allows the user to configure what he wants to be done on
xendomains stop: sysrq, migrate, save, or shutdown.
For this to be safe, a timeout has been introduced (optional).
On start, saved domains may be restored, and not yet started
domains from the auto start dir will be started in addition.
status reports missing domains, restart and reload work as well.

The init script is somewhat SUSE-ish, but it should work on LSB
compliant and on RH based distros as well.

I would appreciate this to be put into tools/examples/init.d/

Signed-off-by: Kurt Garloff <garloff@suse.de>

Best,
-- 
Kurt Garloff, Director SUSE Labs, Novell Inc.

[-- Attachment #1.1.2: init.xendomains --]
[-- Type: text/plain, Size: 11013 bytes --]

#!/bin/bash
#
# /etc/init.d/xendomains
# Start / stop domains automatically when domain 0 boots / shuts down.
#
# chkconfig: 345 99 00
# description: Start / stop Xen domains.
#
# This script offers fairly basic functionality.  It should work on Redhat
# but also on LSB-compliant SuSE releases and on Debian with the LSB package
# installed.  (LSB is the Linux Standard Base)
#
# Based on the example in the "Designing High Quality Integrated Linux
# Applications HOWTO" by Avi Alkalay
# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
#
### BEGIN INIT INFO
# Provides:          xendomains
# Required-Start:    $syslog $remote_fs xend
# Should-Start:
# Required-Stop:     $syslog $remote_fs xend
# Should-Stop:
# Default-Start:     3 4 5
# Default-Stop:      0 1 2 6
# Default-Enabled:   yes
# Short-Description: Start/stop secondary xen domains
# Description:       Start / stop domains automatically when domain 0 
#                    boots / shuts down.
### END INIT INFO

# 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
	exit 0
fi

LOCKFILE=/var/lock/subsys/xendomains
XENDOM_CONFIG=/etc/sysconfig/xendomains

test -r $XENDOM_CONFIG || { echo "$XENDOM_CONFIG not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }

. $XENDOM_CONFIG

# Use the SUSE rc_ init script functions;
# emulate them on LSB, RH and other systems
if test -e /etc/rc.status; then
    # SUSE rc script library
    . /etc/rc.status
else    
    _cmd=$1
    declare -a _SMSG
    if test "${_cmd}" = "status"; then
	_SMSG=(running dead dead unused unknown)
	_RC_UNUSED=3
    else
	_SMSG=(done failed failed missed failed skipped unused failed failed)
	_RC_UNUSED=6
    fi
    if test -e /lib/lsb/init-functions; then
	# LSB    
    	. /lib/lsb/init-functions
	echo_rc()
	{
	    if test ${_RC_RV} = 0; then
		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
	    else
		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
	    fi
	}
    elif test -e /etc/init.d/functions; then
	# REDHAT
	. /etc/init.d/functions
	echo_rc()
	{
	    #echo -n "  [${_SMSG[${_RC_RV}]}] "
	    if test ${_RC_RV} = 0; then
		success "  [${_SMSG[${_RC_RV}]}] "
	    else
		failure "  [${_SMSG[${_RC_RV}]}] "
	    fi
	}
    else    
	# emulate it
	echo_rc()
	{
	    echo "  [${_SMSG[${_RC_RV}]}] "
	}
    fi
    rc_reset() { _RC_RV=0; }
    rc_failed()
    {
	if test -z "$1"; then 
	    _RC_RV=1;
	elif test "$1" != "0"; then 
	    _RC_RV=$1; 
    	fi
	return ${_RC_RV}
    }
    rc_check()
    {
	return rc_failed $?
    }	
    rc_status()
    {
	rc_failed $?
	if test "$1" = "-r"; then _RC_RV=0; shift; fi
	if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi
	if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi
	if test "$1" = "-v"; then echo_rc; shift; fi
	if test "$1" = "-r"; then _RC_RV=0; shift; fi
	return ${_RC_RV}
    }
    rc_exit() { exit ${_RC_RV}; }
    rc_active() 
    {
	if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi
	if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi
	return 1
    }
fi

# Reset status of this service
rc_reset

# read name from xen config file
rdname()
{
    NM=`grep '^name *=' $1 | sed -e 's/^name *= *"\([^"]*\)".*$/\1/' -e 's/%[id]/[0-9]*/g'`
}

rdnames()
{
    NAMES=
    if test ! -d $XENDOMAINS_AUTO -o `/bin/ls $XENDOMAINS_AUTO | wc -l` -eq 0; then 
	return
    fi
    for dom in $XENDOMAINS_AUTO/*; do
	rdname $dom
	if test -z $NAMES; then 
	    NAMES=$NM; 
	else
	    NAMES="$NAMES|$NM"
	fi
    done
}

parseln()
{
    name=`echo "$1" | cut -c0-17`
    name=${name%% *}
    rest=`echo "$1" | cut -c18- `
    read id mem cpu vcpu state tm < <(echo "$rest")
}

is_running()
{
    rdname $1
    RC=1
    while read LN; do
	parseln "$LN"
	if test $id = 0; then continue; fi
	case $name in 
	    ($NM)
		RC=0
		;;
	esac
    done < <(xm list | grep -v '^Name')
    return $RC
}

start() 
{
    if [ -f $LOCKFILE ]; then 
	echo -n "xendomains already running (lockfile exists)"
	return; 
    fi

    if test "$XENDOMAINS_RESTORE" = "true" -a -n "$XENDOMAINS_SAVE" \
	    -a -d $XENDOMAINS_SAVE -a `/bin/ls $XENDOMAINS_SAVE | wc -l` -gt 0; then

	touch $LOCKFILE
	echo -n "Restoring Xen domains:"
	for dom in $XENDOMAINS_SAVE/*; do
	    echo -n " ${dom##*/}"
	    xm restore $dom
	    if [ $? -ne 0 ]; then
		rc_failed $?
		echo -n '!'
	    else
		# mv $dom ${dom%/*}/.${dom##*/}
		rm $dom
	    fi
	done
    fi

    if test -n "$XENDOMAINS_AUTO" -a -d $XENDOMAINS_AUTO \
	    -a `/bin/ls $XENDOMAINS_AUTO | wc -l` -gt 0; then

	touch $LOCKFILE
	echo -n "Starting auto Xen domains:"
	# We expect config scripts for auto starting domains to be in
	# XENDOMAINS_AUTO - they could just be symlinks to files elsewhere

	# Create all domains with config files in XENDOMAINS_AUTO.
	# TODO: We should record which domain name belongs 
	# so we have the option to selectively shut down / migrate later
	for dom in $XENDOMAINS_AUTO/*; do
	    echo -n " ${dom##*/}"
	    if is_running $dom; then
		echo -n "(skip)"
	    else
		xm create --quiet --defconfig $dom
		if [ $? -ne 0 ]; then
		    rc_failed $?
		    echo -n '!'
		fi
	    fi
	done
    fi	
}

all_zombies()
{
    while read LN; do
	parseln "$LN"
	if test $id = 0; then continue; fi
	if test "$state" != "-b---d" -a "$state" != "-----d"; then
	    return 1;
	fi
    done < <(xm list | grep -v '^Name')
    return 0
}

# Wait for max $XENDOMAINS_STOP_MAXWAIT for xm $1 to finish;
# if it has not exited by that time kill it, so the init script will
# succeed within a finite amount of time; if $2 is nonnull, it will
# kill the command as well as soon as no domain (except for zombies)
# are left (used for shutdown --all).
watchdog_xm()
{
    if test -z "$XENDOMAINS_STOP_MAXWAIT" -o "$XENDOMAINS_STOP_MAXWAIT" = "0"; then
	exit
    fi
    usleep 20000
    for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do
	# exit if xm save/migrate/shutdown is finished
	PSAX=`ps axlw | grep "xm $1" | grep -v grep`
	if test -z "$PSAX"; then exit; fi
	echo -n "."; sleep 1
	# go to kill immediately if there's only zombies left
	if all_zombies && test -n "$2"; then break; fi
    done
    sleep 1
    read PSF PSUID PSPID PSPPID < <(echo "$PSAX")
    # kill xm $1
    kill $PSPID >/dev/null 2>&1
}

stop()
{
    # Collect list of domains to shut down
    if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
	rdnames
    fi
    echo -n "Shutting down Xen domains:"
    while read LN; do
	parseln "$LN"
	if test $id = 0; then continue; fi
	echo -n " $name"
	if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
	    case $name in
		($NAMES)
		    # nothing
		    ;;
		(*)
		    echo -n "(skip)"
		    continue
		    ;;
	    esac
	fi
	# XENDOMAINS_SYSRQ chould be something like just "s" 
	# or "s e i u" or even "s e s i u o"
	# for the latter, you should set XENDOMAINS_USLEEP to 1200000 or so
	if test -n "$XENDOMAINS_SYSRQ"; then
	    for sysrq in $XENDOMAINS_SYSRQ; do
		echo -n "(SR-$sysrq)"
		xm sysrq $id $sysrq
		if test $? -ne 0; then
		    rc_failed $?
		    echo -n '!'
		fi
		# usleep just ignores empty arg
		usleep $XENDOMAINS_USLEEP
	    done
	fi
	if test "$state" = "-b---d" -o "$state" = "-----d"; then
	    echo -n "(zomb)"
	    continue
	fi
	if test -n "$XENDOMAINS_MIGRATE"; then
	    echo -n "(migr)"
	    watchdog_xm migrate &
	    WDOG_PID=$!
	    xm migrate $id $XENDOMAINS_MIGRATE
	    if test $? -ne 0; then
		rc_failed $?
		echo -n '!'
		kill $WDOG_PID >/dev/null 2>&1
	    else
		kill $WDOG_PID >/dev/null 2>&1
		continue
	    fi
	fi
	if test -n "$XENDOMAINS_SAVE"; then
	    echo -n "(save)"
	    watchdog_xm save &
	    WDOG_PID=$!
	    xm save $id $XENDOMAINS_SAVE/$name
	    if test $? -ne 0; then
		rc_failed $?
		echo -n '!'
		kill $WDOG_PIG >/dev/null 2>&1
	    else
		kill $WDOG_PIG >/dev/null 2>&1
		continue
	    fi
	fi
	if test -n "$XENDOMAINS_SHUTDOWN"; then
	    # XENDOMAINS_SHUTDOWN should be "--halt --wait"
	    echo -n "(shut)"
	    watchdog_xm shutdown &
	    WDOG_PID=$!
	    xm shutdown $id $XENDOMAINS_SHUTDOWN
	    if test $? -ne 0; then
		rc_failed $?
		echo -n '!'
	    fi
	    kill $WDOG_PIG >/dev/null 2>&1
	fi
    done < <(xm list | grep -v '^Name')

    # NB. this shuts down ALL Xen domains (politely), not just the ones in
    # AUTODIR/*
    # This is because it's easier to do ;-) but arguably if this script is run
    # on system shutdown then it's also the right thing to do.
    if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then
	# XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait"
	echo -n " SHUTDOWN_ALL "
	watchdog_xm shutdown 1 &
	WDOG_PID=$!
	xm shutdown $XENDOMAINS_SHUTDOWN_ALL
	if test $? -ne 0; then
	    rc_failed $?
	    echo -n '!'
	fi
	kill $WDOG_PID >/dev/null 2>&1
    fi

    # Unconditionally delete lock file
    rm -f $LOCKFILE
}

check_domain_up()
{
    while read LN; do
	parseln "$LN"
	if test $id = 0; then continue; fi
	case $name in 
	    ($1)
		return 0
		;;
	esac
    done < <(xm list | grep -v "^Name")
    return 1
}

check_all_auto_domains_up()
{
    if test -z "$XENDOMAINS_AUTO" -o ! -d "$XENDOMAINS_AUTO" \
	    -o `/bin/ls $XENDOMAINS_AUTO | wc -l` -eq 0; then return 0; fi
    missing=
    for nm in $XENDOMAINS_AUTO/*; do
	rdname $nm
	found=0
	if check_domain_up "$NM"; then 
	    echo -n " $name"
	else 
	    missing="$missing $NM"
	fi
    done
    if test -n "$missing"; then
	echo -n " MISS AUTO:$missing"
	return 1
    fi
    return 0
}

check_all_saved_domains_up()
{
    if test -z "$XENDOMAINS_SAVE" -o ! -d "$XENDOMAINS_SAVE" \
	    -o `/bin/ls $XENDOMAINS_SAVE | wc -l` -eq 0; then return 0; fi
    missing=`/bin/ls $XENDOMAINS_SAVE`
    echo -n " MISS SAVED: " $missing
    return 1
}

# This does NOT necessarily restart all running domains: instead it
# stops all running domains and then boots all the domains specified in
# AUTODIR.  If other domains have been started manually then they will
# not get restarted.
# Commented out to avoid confusion!

restart()
{
    stop
    start
}

reload()
{
    restart
}


case "$1" in
    start)
	start
	rc_status
	if test -f $LOCKFILE; then rc_status -v; fi
	;;

    stop)
	stop
	rc_status -v
	;;

    restart)
	restart
	;;
    reload)
	reload
	;;

    status)
	echo -n "Checking for xendomains:" 
	if test ! -f $LOCKFILE; then 
	    rc_failed 3
	else
	    check_all_auto_domains_up
	    rc_status
	    check_all_saved_domains_up
	    rc_status
	fi
	rc_status -v
	;;

    *)
	echo "Usage: $0 {start|stop|restart|reload|status}"
	rc_failed 3
	rc_status -v
	;;
esac

rc_exit

[-- Attachment #1.1.3: sysconfig.xendomains --]
[-- Type: text/plain, Size: 4980 bytes --]

## Path: System/xen
## Description: xen domain start/stop on boot
## Type: string
## Default: 
#
# The xendomains script can send SysRq requests to domains on shutdown.
# If you don't want to MIGRATE, SAVE, or SHUTDOWN, this may be a possibility
# to do a quick and dirty shutdown ("s e i u o") or at least sync the disks
# of the domains ("s").
#
XENDOMAINS_SYSRQ=""

## Type: integer 
## Default: 100000
#
# If XENDOMAINS_SYSRQ is set, this variable determines how long to wait
# (in microseconds) after each SysRq, so the domain has a chance to react.
# If you want to a quick'n'dirty shutdown via SysRq, you may want to set
# it to a relatively high value (1200000).
#
XENDOMAINS_USLEEP=100000

## Type: string
## Default: ""
#
# Set this to a non-empty string if you want to migrate virtual machines
# on shutdown. The string will be passed to the xm migrate DOMID command
# as is: It should contain the target IP address of the physical machine
# to migrate to and optionally parameters like --live. Leave empty if
# you don't want to try virtual machine relocation on shutdown.
# If migration succeeds, neither SAVE nor SHUTDOWN will be executed for
# that domain.
#
XENDOMAINS_MIGRATE=""

## Type: string
## Default: /var/lib/xen/save
#
# Directory to save running domains to when the system (dom0) is
# shut down. Will also be used to restore domains from if # XENDOMAINS_RESTORE
# is set (see below). Leave empty to disable domain saving on shutdown 
# (e.g. because you rather shut domains down).
# If domain saving does succeed, SHUTDOWN will not be executed.
#
XENDOMAINS_SAVE=/var/lib/xen/save

## Type: string
## Default: "--halt --wait"
#
# If neither MIGRATE nor SAVE were enabled or if they failed, you can
# try to shut down a domain by sending it a shutdown request. To do this,
# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting
# for the domain to be really down. Leave empty to skip domain shutdown.
#
XENDOMAINS_SHUTDOWN="--halt --wait"

## Type: string
## Default: "--all --halt --wait"
#
# After we have gone over all virtual machines (resp. all automatically
# started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq,
# migrated, saved and/or shutdown according to the settings above, we
# might want to shutdown the virtual machines that are still running
# for some reason or another. To do this, set this variable to
# "--all --halt --wait", it will be passed to xm shutdown.
# Leave it empty not to do anything special here.
# (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY
# is set.)
# 
XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait"

## Type: boolean
## Default: true
#
# This variable determines whether saved domains from XENDOMAINS_SAVE
# will be restored on system startup. 
#
XENDOMAINS_RESTORE=true

## Type: string
## Default: /etc/xen/auto
#
# This variable sets the directory where domains configurations
# are stored that should be started on system startup automatically.
# Leave empty if you don't want to start domains automatically
# (or just don't place any xen domain config files in that dir).
# Note that the script tries to be clever if both RESTORE and AUTO are 
# set: It will first restore saved domains and then only start domains
# in AUTO which are not running yet. 
# Note that the name matching is somewhat fuzzy.
#
XENDOMAINS_AUTO=/etc/xen/auto

## Type: boolean
## Default: false
# 
# If this variable is set to "true", only the domains started via config 
# files in XENDOMAINS_AUTO will be treated according to XENDOMAINS_SYSRQ,
# XENDOMAINS_MIGRATE, XENDOMAINS_SAVE, XENDMAINS_SHUTDOWN; otherwise
# all running domains will be. 
# Note that the name matching is somewhat fuzzy.
# 
XENDOMAINS_AUTO_ONLY=false

## Type: integer
## Default: 300
#
# On xendomains stop, a number of xm commands (xm migrate, save, shutdown,
# shutdown --all) may be executed. In the worst case, these commands may
# stall forever, which will prevent a successful shutdown of the machine.
# If this variable is non-zero, the script will set up a watchdog timer
# for every of these xm commands and time it out after the number of seconds
# specified by this variable.
# Note that SHUTDOWN_ALL will not be called if no virtual machines or only
# zombies are still running, so you don't need to enable this timeout just
# for the zombie case.
# The setting should be large enough to make sure that migrate/save/shutdown
# can succeed. If you do live migrations, keep in mind that live migration
# of a 1GB machine over Gigabit ethernet may actually take something like
# 100s (assuming that live migration uses 10% of the network # bandwidth).
# Depending on the virtual machine, a shutdown may also require a significant
# amount of time. So better setup this variable to a huge number and hope the
# watchdog never fires.
#
XENDOMAINS_STOP_MAXWAIT=300


[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2005-10-19  9:44 xendomains init script Kurt Garloff
@ 2005-10-26 17:11 ` Ewan Mellor
  2005-10-26 17:27   ` Kurt Garloff
  2006-03-30  3:57 ` Florian Kirstein
  2006-03-30  4:09 ` Florian Kirstein
  2 siblings, 1 reply; 14+ messages in thread
From: Ewan Mellor @ 2005-10-26 17:11 UTC (permalink / raw)
  To: Kurt Garloff, Xen development list

On Wed, Oct 19, 2005 at 11:44:39AM +0200, Kurt Garloff wrote:

> Hi,
> 
> I worked on the xendomains init script.
> 
> It now allows the user to configure what he wants to be done on
> xendomains stop: sysrq, migrate, save, or shutdown.
> For this to be safe, a timeout has been introduced (optional).
> On start, saved domains may be restored, and not yet started
> domains from the auto start dir will be started in addition.
> status reports missing domains, restart and reload work as well.
> 
> The init script is somewhat SUSE-ish, but it should work on LSB
> compliant and on RH based distros as well.
> 
> I would appreciate this to be put into tools/examples/init.d/
> 
> Signed-off-by: Kurt Garloff <garloff@suse.de>

I've committed this now, thanks Kurt.

Ewan.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2005-10-26 17:11 ` Ewan Mellor
@ 2005-10-26 17:27   ` Kurt Garloff
  0 siblings, 0 replies; 14+ messages in thread
From: Kurt Garloff @ 2005-10-26 17:27 UTC (permalink / raw)
  To: Ewan Mellor; +Cc: Xen development list


[-- Attachment #1.1: Type: text/plain, Size: 648 bytes --]

Hi Ewan,

On Wed, Oct 26, 2005 at 06:11:08PM +0100, Ewan Mellor wrote:
> On Wed, Oct 19, 2005 at 11:44:39AM +0200, Kurt Garloff wrote:
> > I would appreciate this to be put into tools/examples/init.d/
> > 
> > Signed-off-by: Kurt Garloff <garloff@suse.de>
> 
> I've committed this now, thanks Kurt.

Cool, thanks!

I think about adding one more feature to the script:
XENDOMAINS_MEMSET0=xxx
would make the script issue xm mem-set 0 xxx on xendomains start
and restore the old mem allocation of dom0 on xendomains stop.

Unless someone tells me it's not worth doing ...

Best,
-- 
Kurt Garloff, Director SUSE Labs, Novell Inc.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2005-10-19  9:44 xendomains init script Kurt Garloff
  2005-10-26 17:11 ` Ewan Mellor
@ 2006-03-30  3:57 ` Florian Kirstein
  2006-03-30  4:09 ` Florian Kirstein
  2 siblings, 0 replies; 14+ messages in thread
From: Florian Kirstein @ 2006-03-30  3:57 UTC (permalink / raw)
  To: Xen development list; +Cc: Kurt Garloff

[-- Attachment #1: Type: text/plain, Size: 2028 bytes --]

Hi,

first: thanks for the nice script :)

I had a (more cosmetic) problem with it:

> The init script is somewhat SUSE-ish, but it should work on LSB
> compliant and on RH based distros as well.
Almost for the LSB-Part: LSB defines that the ini script functions
like "log_success_msg" can be defined as shell aliases:
http://www.linuxbase.org/spec/refspecs/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html

The problem with that: shell aliases are usually not enabled in scripts
(so I'll have to blame LSB for allowing this in init script functions)
and the real problem, they are never used (at least for bash) in
if/then/else blocks or functions, which is exactly what your script
does.

So, IF a distribution decides to implement log_success_msg LSB conforming
as alias, as current RedHat distributions (like RHEL4 and including
FC5) do, this will fail and give "log_success_msg: command not found".
I think this is a bad idea (see above), but can't blame RedHat for
following LSB by the word. And as you check for LSB first and then
for redhat, newer redhat distributions will take the LSB case.

I don't think there's a nice way to make this fully LSB compatible
as these funtions are usually called within functions, but I'd
highly suggest to use a "specific before generic" approach for the
"distribution specific emulations". Means: test for the redhat
specific part first and then use LSB. For the LSB part I'd add
an if-test to check if log_success_msg is an alias and use the
generic emulation in case it is (assuming log_error_msg would be an
alias too when log_success_msg is).

I attached a patch doing exactly this, resulting in a clean run on the
redhat based distributions and fixing it for possible others using an
alias in their LSB conformity scripts, leaving it unchanged for the
rest. Hopefully :) 

@Kurt: as this is your init-script, would you like to review the patch
and in case you think it's OK submit it to the official source tree?
Or whoever is responsible for this :)

(:ul8er, r@y

[-- Attachment #2: init.d-xendomains.patch --]
[-- Type: text/plain, Size: 1327 bytes --]

diff -U 3 -r xen-unstable-orig/tools/examples/init.d/xendomains xen-unstable/tools/examples/init.d/xendomains
--- xen-unstable-orig/tools/examples/init.d/xendomains	2006-03-28 06:11:40.000000000 +0200
+++ xen-unstable/tools/examples/init.d/xendomains	2006-03-30 05:15:13.000000000 +0200
@@ -58,18 +58,7 @@
 	_SMSG=(done failed failed missed failed skipped unused failed failed)
 	_RC_UNUSED=6
     fi
-    if test -e /lib/lsb/init-functions; then
-	# LSB    
-    	. /lib/lsb/init-functions
-	echo_rc()
-	{
-	    if test ${_RC_RV} = 0; then
-		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
-	    else
-		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
-	    fi
-	}
-    elif test -e /etc/init.d/functions; then
+    if test -e /etc/init.d/functions; then
 	# REDHAT
 	. /etc/init.d/functions
 	echo_rc()
@@ -81,6 +70,24 @@
 		failure "  [${_SMSG[${_RC_RV}]}] "
 	    fi
 	}
+    elif test -e /lib/lsb/init-functions; then
+	# LSB    
+    	. /lib/lsb/init-functions
+        if alias log_success_msg >/dev/null 2>/dev/null; then
+	  echo_rc()
+	  {
+	       echo "  [${_SMSG[${_RC_RV}]}] "
+	  }
+        else
+	  echo_rc()
+	  {
+	    if test ${_RC_RV} = 0; then
+		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
+	    else
+		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
+	    fi
+	  }
+        fi
     else    
 	# emulate it
 	echo_rc()

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2005-10-19  9:44 xendomains init script Kurt Garloff
  2005-10-26 17:11 ` Ewan Mellor
  2006-03-30  3:57 ` Florian Kirstein
@ 2006-03-30  4:09 ` Florian Kirstein
  2006-03-30 21:21   ` Daniel Veillard
  2 siblings, 1 reply; 14+ messages in thread
From: Florian Kirstein @ 2006-03-30  4:09 UTC (permalink / raw)
  To: Xen development list

[-- Attachment #1: Type: text/plain, Size: 2114 bytes --]

Hi,

first: thanks for the nice script :) (second: resent, hope my first mail
using a wrong From: is ignored by the list daemon)

I had a (more cosmetic) problem with it:
> The init script is somewhat SUSE-ish, but it should work on LSB
> compliant and on RH based distros as well.
Almost for the LSB-Part: LSB defines that the ini script functions
like "log_success_msg" can be defined as shell aliases:
http://www.linuxbase.org/spec/refspecs/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html

The problem with that: shell aliases are usually not enabled in scripts
(so I'll have to blame LSB for allowing this in init script functions)
and the real problem, they are never used (at least for bash) in
if/then/else blocks or functions, which is exactly what your script
does.

So, IF a distribution decides to implement log_success_msg LSB conforming
as alias, as current RedHat distributions (like RHEL4 and including
FC5) do, this will fail and give "log_success_msg: command not found".
I think this is a bad idea (see above), but can't blame RedHat for
following LSB by the word. And as you check for LSB first and then
for redhat, newer redhat distributions will take the LSB case.

I don't think there's a nice way to make this fully LSB compatible
as these funtions are usually called within functions, but I'd
highly suggest to use a "specific before generic" approach for the
"distribution specific emulations". Means: test for the redhat
specific part first and then use LSB. For the LSB part I'd add
an if-test to check if log_success_msg is an alias and use the
generic emulation in case it is (assuming log_error_msg would be an
alias too when log_success_msg is).

I attached a patch doing exactly this, resulting in a clean run on the
redhat based distributions and fixing it for possible others using an
alias in their LSB conformity scripts, leaving it unchanged for the
rest. Hopefully :) 

@Kurt: as this is your init-script, would you like to review the patch
and in case you think it's OK submit it to the official source tree?
Or whoever is responsible for this :)

(:ul8er, r@y

[-- Attachment #2: init.d-xendomains.patch --]
[-- Type: text/plain, Size: 1327 bytes --]

diff -U 3 -r xen-unstable-orig/tools/examples/init.d/xendomains xen-unstable/tools/examples/init.d/xendomains
--- xen-unstable-orig/tools/examples/init.d/xendomains	2006-03-28 06:11:40.000000000 +0200
+++ xen-unstable/tools/examples/init.d/xendomains	2006-03-30 05:15:13.000000000 +0200
@@ -58,18 +58,7 @@
 	_SMSG=(done failed failed missed failed skipped unused failed failed)
 	_RC_UNUSED=6
     fi
-    if test -e /lib/lsb/init-functions; then
-	# LSB    
-    	. /lib/lsb/init-functions
-	echo_rc()
-	{
-	    if test ${_RC_RV} = 0; then
-		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
-	    else
-		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
-	    fi
-	}
-    elif test -e /etc/init.d/functions; then
+    if test -e /etc/init.d/functions; then
 	# REDHAT
 	. /etc/init.d/functions
 	echo_rc()
@@ -81,6 +70,24 @@
 		failure "  [${_SMSG[${_RC_RV}]}] "
 	    fi
 	}
+    elif test -e /lib/lsb/init-functions; then
+	# LSB    
+    	. /lib/lsb/init-functions
+        if alias log_success_msg >/dev/null 2>/dev/null; then
+	  echo_rc()
+	  {
+	       echo "  [${_SMSG[${_RC_RV}]}] "
+	  }
+        else
+	  echo_rc()
+	  {
+	    if test ${_RC_RV} = 0; then
+		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
+	    else
+		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
+	    fi
+	  }
+        fi
     else    
 	# emulate it
 	echo_rc()

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2006-03-30  4:09 ` Florian Kirstein
@ 2006-03-30 21:21   ` Daniel Veillard
  2006-03-31  4:27     ` Florian Kirstein
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Veillard @ 2006-03-30 21:21 UTC (permalink / raw)
  To: Florian Kirstein; +Cc: Xen development list

On Thu, Mar 30, 2006 at 06:09:33AM +0200, Florian Kirstein wrote:
> Hi,
> 
> first: thanks for the nice script :) (second: resent, hope my first mail
> using a wrong From: is ignored by the list daemon)
> 
> I had a (more cosmetic) problem with it:
> > The init script is somewhat SUSE-ish, but it should work on LSB
> > compliant and on RH based distros as well.
> Almost for the LSB-Part: LSB defines that the ini script functions
> like "log_success_msg" can be defined as shell aliases:
> http://www.linuxbase.org/spec/refspecs/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
> 
> The problem with that: shell aliases are usually not enabled in scripts
> (so I'll have to blame LSB for allowing this in init script functions)
> and the real problem, they are never used (at least for bash) in
> if/then/else blocks or functions, which is exactly what your script
> does.
> 
> So, IF a distribution decides to implement log_success_msg LSB conforming
> as alias, as current RedHat distributions (like RHEL4 and including
> FC5) do, this will fail and give "log_success_msg: command not found".
> I think this is a bad idea (see above), but can't blame RedHat for
> following LSB by the word. And as you check for LSB first and then
> for redhat, newer redhat distributions will take the LSB case.
> 
> I don't think there's a nice way to make this fully LSB compatible
> as these funtions are usually called within functions, but I'd
> highly suggest to use a "specific before generic" approach for the
> "distribution specific emulations". Means: test for the redhat
> specific part first and then use LSB. For the LSB part I'd add
> an if-test to check if log_success_msg is an alias and use the
> generic emulation in case it is (assuming log_error_msg would be an
> alias too when log_success_msg is).
> 
> I attached a patch doing exactly this, resulting in a clean run on the
> redhat based distributions and fixing it for possible others using an
> alias in their LSB conformity scripts, leaving it unchanged for the
> rest. Hopefully :) 
> 
> @Kurt: as this is your init-script, would you like to review the patch
> and in case you think it's OK submit it to the official source tree?
> Or whoever is responsible for this :)
> 
> (:ul8er, r@y


+1

   Associated bug at Red Hat is
 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=171056

yes this is a problem, but I didn't tried the patch yet, I assume you tested
it on FC5,

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2006-03-30 21:21   ` Daniel Veillard
@ 2006-03-31  4:27     ` Florian Kirstein
  2007-02-28  5:20       ` Florian Kirstein
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Kirstein @ 2006-03-31  4:27 UTC (permalink / raw)
  To: Xen development list; +Cc: Daniel Veillard

Hi,

>  Associated bug at Red Hat is
>  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=171056
Oh, if I had known the old version (completely different from the more
advanced current one) of the script already had the same problem, I had
searched there :)

> yes this is a problem, but I didn't tried the patch yet, I assume you tested
> it on FC5,
The patch works for xen 3.0.1 (and newer, possibly some older)
on all redhat-based distributions, as it simply moves the redhat check
before the LSB check (like Jonathan did for the older script).
Additionally it "fixes" the alias problem for possible other
distributions which also use aliases to build the LSB compatibility.

And yes: the patch applies cleanly when added for example as Patch13
(using -p1) to the FC5 xen SRPM, even though I intended it to be included
in the main xen distribution as I don't see any negative impacts - and it's
a bug in the script in the first place to assume no aliases are used for
LSB.

For RedHat I'd independently suggest to follow 
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=171052
and change the lsb-compatibility. Sure, LSB explicitly allows use of
aliases as the link in my original mail shows, so it is not really
a bug if you read the spec by the word, but IMHO it's still a bad
idea to do so :) Using functions like suggested in Bug 158183 and the
one linked above simply will result in less trouble also in possible
other cases.

(:ul8er, r@y
(oh my god, how much text for such a simple issue, sorry to all :)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2006-03-31  4:27     ` Florian Kirstein
@ 2007-02-28  5:20       ` Florian Kirstein
  2007-02-28 14:51         ` Keir Fraser
  0 siblings, 1 reply; 14+ messages in thread
From: Florian Kirstein @ 2007-02-28  5:20 UTC (permalink / raw)
  To: Xen development list

[-- Attachment #1: Type: text/plain, Size: 2207 bytes --]

Hi,

replying to my almost a year old message:
> The patch works for xen 3.0.1 (and newer, possibly some older)
... I've finally build this as patch for current xen-unstable.hg.
RedHat followed the suggestion to reimplement LSB compatibility in
RHEL5, but for all the others (including FC6) this patch still is
needed. It's also referenced as solution in 
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=171056
and I'm using it since I first posted it on all my xen builds, don't
see problems there, should not harm non-redhat dists.

(:ul8er, r@y

# HG changeset patch
# User ray@build.ray.net
# Node ID a96bf6276e4fa1323a0ffe260f0029018b57dfda
# Parent  1c5e6239a8d0381fdbf56d4926f986d7f0ec07c0
Fix init.d/xendomains startup script so log_error and log_success
will also work on redhat-based distributions before RHEL 5. See
discussion "xendomains init script" about a year ago on xen-devel.

Signed-off-by: Florian Kirstein <ray@ray.net>

diff -r 1c5e6239a8d0 -r a96bf6276e4f tools/examples/init.d/xendomains
--- a/tools/examples/init.d/xendomains	Sun Feb 25 23:58:33 2007 -0600
+++ b/tools/examples/init.d/xendomains	Wed Feb 28 06:08:20 2007 +0100
@@ -58,18 +58,7 @@ else
 	_SMSG=(done failed failed missed failed skipped unused failed failed)
 	_RC_UNUSED=6
     fi
-    if test -e /lib/lsb/init-functions; then
-	# LSB    
-    	. /lib/lsb/init-functions
-	echo_rc()
-	{
-	    if test ${_RC_RV} = 0; then
-		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
-	    else
-		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
-	    fi
-	}
-    elif test -e /etc/init.d/functions; then
+    if test -e /etc/init.d/functions; then
 	# REDHAT
 	. /etc/init.d/functions
 	echo_rc()
@@ -81,6 +70,24 @@ else
 		failure "  [${_SMSG[${_RC_RV}]}] "
 	    fi
 	}
+    elif test -e /lib/lsb/init-functions; then
+	# LSB    
+    	. /lib/lsb/init-functions
+        if alias log_success_msg >/dev/null 2>/dev/null; then
+	  echo_rc()
+	  {
+	       echo "  [${_SMSG[${_RC_RV}]}] "
+	  }
+        else
+	  echo_rc()
+	  {
+	    if test ${_RC_RV} = 0; then
+		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
+	    else
+		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
+	    fi
+	  }
+        fi
     else    
 	# emulate it
 	echo_rc()

[-- Attachment #2: xendomains.patch --]
[-- Type: text/plain, Size: 1653 bytes --]

# HG changeset patch
# User ray@build.ray.net
# Node ID a96bf6276e4fa1323a0ffe260f0029018b57dfda
# Parent  1c5e6239a8d0381fdbf56d4926f986d7f0ec07c0
Fix init.d/xendomains startup script so log_error and log_success
will also work on redhat-based distributions before RHEL 5. See
discussion "xendomains init script" about a year ago on xen-devel.

Signed-off-by: Florian Kirstein <ray@ray.net>

diff -r 1c5e6239a8d0 -r a96bf6276e4f tools/examples/init.d/xendomains
--- a/tools/examples/init.d/xendomains	Sun Feb 25 23:58:33 2007 -0600
+++ b/tools/examples/init.d/xendomains	Wed Feb 28 06:08:20 2007 +0100
@@ -58,18 +58,7 @@ else
 	_SMSG=(done failed failed missed failed skipped unused failed failed)
 	_RC_UNUSED=6
     fi
-    if test -e /lib/lsb/init-functions; then
-	# LSB    
-    	. /lib/lsb/init-functions
-	echo_rc()
-	{
-	    if test ${_RC_RV} = 0; then
-		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
-	    else
-		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
-	    fi
-	}
-    elif test -e /etc/init.d/functions; then
+    if test -e /etc/init.d/functions; then
 	# REDHAT
 	. /etc/init.d/functions
 	echo_rc()
@@ -81,6 +70,24 @@ else
 		failure "  [${_SMSG[${_RC_RV}]}] "
 	    fi
 	}
+    elif test -e /lib/lsb/init-functions; then
+	# LSB    
+    	. /lib/lsb/init-functions
+        if alias log_success_msg >/dev/null 2>/dev/null; then
+	  echo_rc()
+	  {
+	       echo "  [${_SMSG[${_RC_RV}]}] "
+	  }
+        else
+	  echo_rc()
+	  {
+	    if test ${_RC_RV} = 0; then
+		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
+	    else
+		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
+	    fi
+	  }
+        fi
     else    
 	# emulate it
 	echo_rc()

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2007-02-28  5:20       ` Florian Kirstein
@ 2007-02-28 14:51         ` Keir Fraser
  2007-02-28 17:26           ` Florian Kirstein
  0 siblings, 1 reply; 14+ messages in thread
From: Keir Fraser @ 2007-02-28 14:51 UTC (permalink / raw)
  To: Florian Kirstein, Xen development list

On 28/2/07 05:20, "Florian Kirstein" <xenlist@custom.ray.net> wrote:

> ... I've finally build this as patch for current xen-unstable.hg.
> RedHat followed the suggestion to reimplement LSB compatibility in
> RHEL5, but for all the others (including FC6) this patch still is
> needed. It's also referenced as solution in
> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=171056
> and I'm using it since I first posted it on all my xen builds, don't
> see problems there, should not harm non-redhat dists.

Why is the LSB case moved to after the RedHat case? LSB looks like a more
specific check (it looks for a file with 'lsb' in the path for a start!) so
wouldn't it be better to leave it where it is? Or does that not work?

 -- Keir

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2007-02-28 14:51         ` Keir Fraser
@ 2007-02-28 17:26           ` Florian Kirstein
  0 siblings, 0 replies; 14+ messages in thread
From: Florian Kirstein @ 2007-02-28 17:26 UTC (permalink / raw)
  To: Xen development list; +Cc: Keir Fraser

Hi,

> Or does that not work?
Exactly. The LSB way does not work on Redhat-based distributions prior
to RHEL5. And that's not /really/ a RH bug, as LSB explicitly allows their
alias implementation, which unfortunately can't be used the way the script
tries to. Really a silly problem caused by the LSB spec allowing aliases.

> Why is the LSB case moved to after the RedHat case? LSB looks like a more
> specific check (it looks for a file with 'lsb' in the path for a start!)
No, LSB is the most generic check, as most distributions have LSB
compliance scripts today. As the script's first check is for SUSE's
/etc/rc.status, it's only logical to check for RedHat's /etc/init.d/functions
second, and only then go for the generic case, LSB. Especially as that
doesn't work on all current RedHat's and causes
/etc/rc.d/init.d/xendomains: line 67: log_success_msg: command not found
errors turning up in all (Fedora, Redhat) bugzillas :)

I don't see any non-redhat Distribution having an /etc/init.d/functions
(which does not implement the RH success and failure function), so it should
cause no problem to move this up, but it will make the problem disappear on
all RH and Fedora Versions out there. And as RHs old LSB implementation
isn't a bug (according to the spec), we have to fix our init script and can't
hope for fixes in older Fedora/RedHat's LSB. See my post last year...

(:ul8er, r@y

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2005-10-27 14:15 Ian Pratt
@ 2005-10-27 15:16 ` Chris Bainbridge
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Bainbridge @ 2005-10-27 15:16 UTC (permalink / raw)
  To: Xen development list

On 27/10/05, Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk> wrote:
> It would be good if you could write a few notes to describe what the
> runes you use to start screen are, and whether you think it makes sense
> to integrate this with 'xm'?

Ok, this sequence will create a single screen session with a dom0
window, then opens a named window for each domU. The screen is
initially detached (ie. you can't see it), you can attach to it with
screen -r or screen -x. You then see all of your domains as windows
(ctrl-a " for a list).

> > start() {
> >         einfo "Starting ${AUTODIR} Xen domains"
> >         if [[ ${SCREEN} == "yes" ]]; then
> >                 screen -d -m -S xen -t dom0

"-d -m"        start screen session, but do not attach to it
"-S xen"      call the session "xen"
"-t dom0"    sets the title of the initial console - this will be a
normal terminal on dom0.

> >                 screen -r xen -X zombie dr

"-r xen"    name of session
"-X"         send a command
"zombie dr"    the command. By default,  a window closes when it's
process dies. This changes that so windows remain persistent, so you
can see xen domains reboot etc. The d and r keys are shortcuts to
destroy/resurrect the window process, at the time it seemed like a
good idea to be able to hit "r" in the console window and restart the
domain.

> >                 logrotate -f /usr/share/xen/xen-consoles-logrotate

force a run of a logrotate script which rotates the files in
/var/log/xen-consoles/

> >                 screen -r xen -X logfile /var/log/xen-consoles/%t

send a command to session "xen". logfile specifies a generic filename,
%t is replaced with the name of the window for each domainU session.

> >                 screen -r xen -X logfile flush 1

flush the log every second

> >                 screen -r xen -X deflog on

turn on logging by default

> >         fi
> >         # Create all domains with config files in AUTODIR.
> >         for dom in $(ls ${AUTODIR}/* 2>/dev/null); do
> >                 name=$(get_domname ${dom})
> >                 if ! is_running ${name} ; then
> >                         ebegin "  Starting domain ${name}"
> >                         if [[ ${SCREEN} == "yes" ]]; then
> >                                 screen -r xen -X screen -t
> > ${name} xm create ${dom} -c

"screen -r xen"    select screen called "xen"
"-X screen -t name"    run internal screen command "screen -t name"
which creates a window with the given name, and runs "xm create
/etc/xen/auto/dom -c" inside that window

On stop():     screen -r xen -X quit

This closes the screen session called "xen".

Does it make sense to integrate this with xm? I think so, since then
you can have a console screen session for any domain, not just ones
you autostart. Also it multiplexes access to the console - I'm not
sure what happens if two users run "xm console" at the same time? I
don't think it works. The console logs are useful for viewing domain
crashes and other things that don't make it to syslog. And it's nice
to be able to reboot in a window and see the full shutdown and
startup.

Regards,
Chris

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: xendomains init script
@ 2005-10-27 14:15 Ian Pratt
  2005-10-27 15:16 ` Chris Bainbridge
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Pratt @ 2005-10-27 14:15 UTC (permalink / raw)
  To: Chris Bainbridge, Xen development list

 
> Here's another feature... I'm not sure if anyone else will 
> need this, but we had a requirement to log all console 
> output, and to have console windows available at all time and 
> potentially multiplexed between users. I solved it by having 
> each xen domain start up in a persistent window inside a 
> screen session.

We've been thinking about having an option to fork off a 'screen'
session when creating a vm.

It would be good if you could write a few notes to describe what the
runes you use to start screen are, and whether you think it makes sense
to integrate this with 'xm'?

Thanks,
Ian

 
> My (gentoo) xendomains start() and stop() currently look like:
> 
> start() {
>         einfo "Starting ${AUTODIR} Xen domains"
>         if [[ ${SCREEN} == "yes" ]]; then
>                 screen -d -m -S xen -t xen-cbc0
>                 screen -r xen -X zombie dr
>                 logrotate -f /usr/share/xen/xen-consoles-logrotate
>                 screen -r xen -X logfile /var/log/xen-consoles/%t
>                 screen -r xen -X logfile flush 1
>                 screen -r xen -X deflog on
>         fi
>         # Create all domains with config files in AUTODIR.
>         for dom in $(ls ${AUTODIR}/* 2>/dev/null); do
>                 name=$(get_domname ${dom})
>                 if ! is_running ${name} ; then
>                         ebegin "  Starting domain ${name}"
>                         if [[ ${SCREEN} == "yes" ]]; then
>                                 screen -r xen -X screen -t 
> ${name} xm create ${dom} -c
>                         else
>                                 xm create --quiet ${dom}
>                         fi
>                         eend $?
>                 else
>                         einfo "  Not Starting domain ${name} 
> - allready running"
>                 fi
>         done

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: xendomains init script
  2005-10-26 19:05 Ian Pratt
@ 2005-10-26 23:35 ` Chris Bainbridge
  0 siblings, 0 replies; 14+ messages in thread
From: Chris Bainbridge @ 2005-10-26 23:35 UTC (permalink / raw)
  To: Xen development list

On 26/10/05, Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk> wrote:
> > I think about adding one more feature to the script:

Here's another feature... I'm not sure if anyone else will need this,
but we had a requirement to log all console output, and to have
console windows available at all time and potentially multiplexed
between users. I solved it by having each xen domain start up in a
persistent window inside a screen session.

My (gentoo) xendomains start() and stop() currently look like:

start() {
        einfo "Starting ${AUTODIR} Xen domains"
        if [[ ${SCREEN} == "yes" ]]; then
                screen -d -m -S xen -t xen-cbc0
                screen -r xen -X zombie dr
                logrotate -f /usr/share/xen/xen-consoles-logrotate
                screen -r xen -X logfile /var/log/xen-consoles/%t
                screen -r xen -X logfile flush 1
                screen -r xen -X deflog on
        fi
        # Create all domains with config files in AUTODIR.
        for dom in $(ls ${AUTODIR}/* 2>/dev/null); do
                name=$(get_domname ${dom})
                if ! is_running ${name} ; then
                        ebegin "  Starting domain ${name}"
                        if [[ ${SCREEN} == "yes" ]]; then
                                screen -r xen -X screen -t ${name} xm
create ${dom} -c
                        else
                                xm create --quiet ${dom}
                        fi
                        eend $?
                else
                        einfo "  Not Starting domain ${name} - allready running"
                fi
        done
}

stop() {
        einfo "Shutting down ${AUTODIR} Xen domains"
        # Stop all domains with config files in AUTODIR.
        for dom in $(ls ${AUTODIR}/* 2>/dev/null); do
                name=$(get_domname ${dom})
                if is_running ${name} ; then
                        ebegin "  Stopping domain ${name}"
                                xm shutdown --wait ${name} >/dev/null
                        eend $?
                else
                        einfo "  Not Stopping domain ${name} - not running"
                fi
        done
        if [[ ${SCREEN} == "yes" ]]; then
                screen -r xen -X quit
        fi
}

It should be easy to adapt this to the generic script if others find it useful.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: xendomains init script
@ 2005-10-26 19:05 Ian Pratt
  2005-10-26 23:35 ` Chris Bainbridge
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Pratt @ 2005-10-26 19:05 UTC (permalink / raw)
  To: Kurt Garloff, Ewan Mellor; +Cc: Xen development list

> I think about adding one more feature to the script:
> XENDOMAINS_MEMSET0=xxx
> would make the script issue xm mem-set 0 xxx on xendomains 
> start and restore the old mem allocation of dom0 on xendomains stop.
> 
> Unless someone tells me it's not worth doing ...

You know about dom0-min-mem in xend-config.sxp, right? It's a related
feature, but I don't object to adding the one you're requesting.

Ian

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-02-28 17:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-19  9:44 xendomains init script Kurt Garloff
2005-10-26 17:11 ` Ewan Mellor
2005-10-26 17:27   ` Kurt Garloff
2006-03-30  3:57 ` Florian Kirstein
2006-03-30  4:09 ` Florian Kirstein
2006-03-30 21:21   ` Daniel Veillard
2006-03-31  4:27     ` Florian Kirstein
2007-02-28  5:20       ` Florian Kirstein
2007-02-28 14:51         ` Keir Fraser
2007-02-28 17:26           ` Florian Kirstein
2005-10-26 19:05 Ian Pratt
2005-10-26 23:35 ` Chris Bainbridge
2005-10-27 14:15 Ian Pratt
2005-10-27 15:16 ` Chris Bainbridge

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.