Subject: rc.d script for starting Xen domains
To: None <port-xen@NetBSD.org>
From: Johnny C. Lam <jlam@pkgsrc.org>
List: port-xen
Date: 10/02/2005 18:20:13
--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I've attached the rc.d script that I use to automatically start and
shutdown Xen unpriviliged domains. The following variables may be
set in /etc/rc.conf:
xendomains This required variable is a whitespace-separated list
of Xen domains to start/stop, e.g.
xendomains="dom1 dom2 dom3"
xendomains_cfg This optional variable is a format string that represents
the path to the configuration file for domains. "%s"
in the format string is substituted with the name of
the domain, e.g. xendomains_cfg="/xen/%s/xen.conf".
The default is "/usr/pkg/etc/xen/%s".
The "xendomains_cfg" shouldn't need to be set if you follow the
convention used by the Xen how-to guide of naming the config files
stored in /usr/pkg/etc/xen after the name of the domain.
Cheers,
-- Johnny Lam <jlam@pkgsrc.org>
--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=xendomains
#!/bin/sh
#
# $NetBSD$
#
# PROVIDE: xendomains
# REQUIRE: xend
# KEYWORD: shutdown
. /etc/rc.subr
name="xendomains"
ctl_command="/usr/pkg/sbin/xm"
start_cmd="xendomains_start"
stop_cmd="xendomains_stop"
xendomains_start()
{
echo "Starting xen domains."
: ${xendomains_cfg="/usr/pkg/etc/xen/%s"}
for domain in $xendomains; do
case "$domain" in
"") ;;
*) file=`printf "${xendomains_cfg}" $domain`
if [ -f "$file" ]; then
${ctl_command} create "$file"
fi
;;
esac
done
}
xendomains_stop()
{
echo "Stopping xen domains."
${ctl_command} shutdown --halt --wait --all
}
load_rc_config $name
run_rc_command "$1"
--0OAP2g/MAC+5xKAE--