Since no one replied, I just went ahead and used uml_mconsole. I thought
anyone using UML and Ubuntu might find the resulting script useful.
Basically it starts n UML instances automatically and then shuts them
down nicely when the time comes. It's also integrated with Ubuntu's
startup script architecture.
To use it, copy it to /etc/init.d/uml, be sure to set the configuration
variables to suit you, then run
# chmod 755 /etc/init.d/uml
# update-rc.d uml defaults
It runs as a non-privileged user using sudo, so I'd recommend a system
user named something like 'uml', but be sure the user has rw access to
$UML_DIR and your COW files.
Then to use it,
# /etc/init.d/uml start
# /etc/init.d/uml stop
which will of course be done automatically on startup and shutdown of
the host system.
One more note, it requires the guest to have been compiled with MCONSOLE
and MCONSOLE_EXEC, and to have uml-utilities installed.
Hope it's useful for someone.
-Ian
-------------------------------------------------------------------
- start script
#!/bin/sh
# /etc/init.d/uml start and stop UML instances on Ubuntu
#
# by Ian Smith-Heisters <[EMAIL PROTECTED]>
# 6 January, 2006
# in case it matters, this script is liscensed under the GPL
#
# Should be set to run at runlevels 2345
# Start:40 Stop:60
# Configuration Variables
USER="uml"
UML_EXEC="/usr/bin/vmlinux"
UML_DIR="/var/uml"
COW_FS=(server-1.cow server-2.cow server-n.cow)
MEMORY="512M"
OPTIONS="con=null"
# End of configuration
# Load in Ubuntu functions
. /lib/lsb/init-functions
if [ ! -f ${UML_EXEC} ]; then
log_warning_msg "${UML_EXEC} not found!";
exit 1;
fi
function start_instance {
echo "starting UML instance ${1%%\.*}..."
sudo -u $USER $UML_EXEC umid=${1%%\.*} ubd0=$UML_DIR/$1
$OPTIONS mem=$MEMORY eth0=tuntap,tap$2 uml_dir=$UML_DIR &
}
start_uml() {
log_begin_msg "Starting UML instances..."
i=0
for cow in [EMAIL PROTECTED]
do
start_instance $cow $i
((i++))
done
count=15
while ([ ${count} != 0 ]) do
let count=${count}-1
if [ "`pidof $UML_EXEC}`" ]; then
count=0
else
sleep 1
fi
done
if [ "`pidof ${UML_EXEC}`" ]; then
log_end_msg 0
else
log_end_msg 1
fi
}
stop_uml() {
log_begin_msg "Stopping UML instances..."
if [ "`pidof ${UML_EXEC}`" ] ; then
for cow in [EMAIL PROTECTED]
do
uml_mconsole $UML_DIR/${cow%%\.*}/mconsole exec halt
((i++))
done
# Wait until the timeout
count=120
while ([ ${count} != 0 ]) do
let count=${count}-1
if [ "`pidof ${UML_EXEC}`" ] ; then
sleep 1
else
count=0
fi
done
# If it's not dead yet, kill it.
if [ "`pidof ${UML_EXEC}`" ] ; then
echo " Polite termination timed out."
kill -TERM `pidof ${UML_EXEC}`
count=20
while ([ ${count} != 0 ]) do
let count=${count}-1
if [ "`pidof ${UML_EXEC}`" ] ; then
sleep 1
else
count=0
fi
done
fi
if [ "`pidof ${UML_EXEC}`" ] ; then
echo " TIMEOUT!"
kill -KILL `${UML_EXEC}`
fi
if [ "`pidof ${UML_EXEC}`" ] ; then
log_end_msg 1
else
log_end_msg 0
fi
else
log_end_msg 1
fi
}
case "$1" in
start)
start_uml
;;
stop)
stop_uml
;;
restart)
stop_uml
start_uml
;;
*)
log_success_msg 'Usage: /etc/init.d/virtual-servers
{start|stop|restart}'
exit 1
;;
esac
exit 0
;;
- end script
-------------------------------------------------------------------
Ian Smith-Heisters wrote:
Hi all,
does anyone have a readme/howto for UMLd? The 0.3.2 I got from David
Coulson's site doesn't come with one, and I can't find one anywhere
else. It doesn't look too complicated, but there are a few things I'd
rather not be guessing about.
Thanks
-Ian
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user