[Frugalware-darcs] frugalware-current: qemu-0.9.0-1-i686

VMiklos vmiklos at frugalware.org
Sat Jun 16 04:03:43 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=frugalware-current;a=darcs_commitdiff;h=20070616020124-e2957-25c049811c4443616a352bf2702f2683bfad8afa.gz;

[qemu-0.9.0-1-i686
VMiklos <vmiklos at frugalware.org>**20070616020124
 added rc.qemu-system and its sysconfig file
] {
hunk ./source/xapps-extra/qemu/FrugalBuild 15
+	rc.qemu-system qemu-system
hunk ./source/xapps-extra/qemu/FrugalBuild 20
+          '2ba7e84a4bc38907202340ba1323a224dbd5f597' \
+          'b1c2b53ef74d1461bbd4f83b8a4f1180187f6a30' \
hunk ./source/xapps-extra/qemu/FrugalBuild 41
+	Frcd2 qemu-system
+	Ffile /etc/sysconfig/qemu-system
addfile ./source/xapps-extra/qemu/qemu-system
hunk ./source/xapps-extra/qemu/qemu-system 1
+#
+# /etc/sysconfig/qemu-system
+#
+# confiugation file for qemu system emulation
+#
+
+# parameters for machines to start/stop
+
+# please don't use the -monitor parameter, rc.qemu-system appends that so that
+# it will be able to properly stop your machines
+
+# please also don't forget to update inittab to do a shutdown instead of a
+# reboot for ctrl-alt-del. see the 'Creating a root image' section of the
+# documentation of the user-mode-linux package for more information
+
+machines=('qemu -hda /home/qemu/hda.img -redir tcp:1022::22 -vnc :0')
+
+# how often in seconds rc.qemu polls to check if the machines are shut down
+SHUTDOWN_POLL=2
+# don't wait more than this for machines to properly shut down
+SHUTDOWN_TIMEOUT=300
+
+# vim: ft=sh
addfile ./source/xapps-extra/qemu/rc.qemu-system
hunk ./source/xapps-extra/qemu/rc.qemu-system 1
+#!/bin/bash
+
+# (c) 2007 Miklos Vajna <vmiklos at frugalware.org>
+# rc.qemu-system for Frugalware
+# distributed under GPL License
+
+# chkconfig: 2345 44 56
+# description: Manage UML machines
+
+source /lib/initscripts/functions
+TEXTDOMAINDIR=/lib/initscripts/functions
+TEXTDOMAIN=qemu-system
+
+actions=(restart start status stop)
+daemon=$"Qemu virtual machines"
+
+pid="cat /var/run/qemu0.pid 2> /dev/null"
+
+rc_start()
+{
+	start_msg
+	if [[ "$(eval ${pid})" == "" ]] ; then
+		source /etc/sysconfig/qemu-system
+		num=0
+		for i in "${machines[@]}"
+		do
+			$i -monitor unix:/var/run/qemu$num.sock,server,nowait &> /var/log/qemu$num.log &
+			echo $! > /var/run/qemu$num.pid
+			num=$(($num+1))
+		done
+		ok $?
+	else
+		ok 999
+	fi
+}
+
+rc_status()
+{
+	msg "$daemon are"
+	if ! ls /var/run/qemu*.pid &>/dev/null; then
+		ok 998
+		return
+	fi
+	# if one of the machines is running then the service is on
+	for i in /var/run/qemu*.pid
+	do
+		if [ -d "/proc/`cat $i`" ]; then
+			ok 997
+			return 0
+		fi
+	done
+	ok 998
+	return 1
+}
+
+rc_stop()
+{
+	source /etc/sysconfig/qemu-system
+	stop_msg
+	if [[ "$(eval ${pid})" != "" ]] ; then
+		# send ctrl-alt-del to each machine
+		for i in /var/run/qemu*.sock
+		do
+			python -c "import socket; sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM); \
+sock.connect('$i'); \
+sock.send('sendkey ctrl-alt-delete\n')"
+		done
+		# now wait till they are shut down
+		TIME=0
+		while true
+		do
+			if ! rc_status &>/dev/null; then
+				rm -f /var/run/qemu*.pid
+				ok 0
+				return
+			fi
+			echo -n .
+			sleep $SHUTDOWN_POLL
+			TIME=`expr $TIME + $SHUTDOWN_POLL`
+			if [ $TIME -gt $SHUTDOWN_TIMEOUT ]; then
+				break
+			fi
+		done
+		rm -f /var/run/qemu*.pid
+		ok 1
+	else
+		ok 999
+	fi
+}
+
+rc_exec $1
}


More information about the Frugalware-darcs mailing list