From 416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Thu, 2 Sep 2010 17:50:49 +0200 Subject: change dir structure --- src/os-plugins/plugins/qemukvm/XX_qemukvm.sh | 112 +++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/os-plugins/plugins/qemukvm/XX_qemukvm.sh (limited to 'src/os-plugins/plugins/qemukvm/XX_qemukvm.sh') diff --git a/src/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/src/os-plugins/plugins/qemukvm/XX_qemukvm.sh new file mode 100644 index 00000000..8a41ff3b --- /dev/null +++ b/src/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -0,0 +1,112 @@ +# Copyright (c) 2009..2010 - RZ Uni Freiburg +# Copyright (c) 2008..2010 - OpenSLX GmbH +# +# This program/file is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your feedback to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org +# +# Script is included from init via the "." load function - thus it has all +# variables and functions available + +# include default directories +. /etc/openslx.conf + +CONFFILE=/initramfs/plugin-conf/qemukvm.conf +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm +PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/qemukvm +VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/qemukvm +LOGDIR=/mnt/${OPENSLX_DEFAULT_LOGDIR} + +# check if the configuration file is available +if [ -e ${CONFFILE} ]; then + + # load needed variables + . ${CONFFILE} + + # Test if this plugin is activated... more or less useless with the + # new plugin system + if [ ${qemukvm_active} -ne 0 2>/dev/null ]; then + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'qemukvm' os-plugin ..."; + + # load general configuration + . /initramfs/machine-setup + + # copy virtualization include files and qemukvm.conf to config dir + testmkd ${PLUGINCONFDIR} + cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} + cp ${CONFFILE} ${PLUGINCONFDIR} + +# # check for the virtualization CPU features +# if grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then +# [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module" +# echo "kvm=intel" >> ${PLUGINCONFDIR}/qemukvm.conf +# elif grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then +# [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module" +# echo "kvm=amd" >> ${PLUGINCONFDIR}/qemukvm.conf +# elif modprobe ${MODPRV} kqemu ; then +# [ $DEBUGLEVEL -gt 0 ] && \ +# error " * Successfully loaded the kqemu module, but loading of kvm_amd \ +#or kvm_intel\n failed, because no virtualization extenstion found in this \ +#CPU. Please\n enable the extension within your machines BIOS or get another \ +#CPU." nonfatal +# else +# error " * All module loading failed including the kqemu module, which \ +#was either\n not found or couldn't be loaded for other reasons. Thus using \ +#qemu(-kvm)\n makes not much sense." nonfatal +# fi + +# # load the tunnel device module +# modprobe tun 2>/dev/null + + # get source of qemukvm image server (get type, server and path) + if strinstr "/" "${qemukvm_imagesrc}" ; then + qkimgprot=$(uri_token ${qemukvm_imagesrc} prot) + qkimgserv=$(uri_token ${qemukvm_imagesrc} server) + qkimgpath="$(uri_token ${qemukvm_imagesrc} path)" + fi + if [ -n "${qkimgserv}" ] ; then + # directory where qemu images are expected in + mnttarget=/mnt/var/lib/virt/qemukvm + # mount the qemukvm image source readonly (ro) + fsmount ${qkimgprot} ${qkimgserv} ${qkimgpath} ${mnttarget} ro + else + [ $DEBUGLEVEL -gt 1 ] && error " * Incomplete information in variable \ +${qemukvm_imagesrc}." nonfatal + fi + + # create a network configuration template (variables should be setable in + # the future, see vmware plugin) + natnetwork="192.168.101" + honetwork="192.168.102" + echo -e "nataddress=${natnetwork}.254/24\nhoaddress=${honetwork}.254/24" \ + >${PLUGINCONFDIR}/network.conf + + # copy the runlevel script (proper place for all distros??) + cp /mnt/${PLUGINDIR}/qemukvm /mnt/etc/init.d + chmod 0755 /mnt/etc/init.d/qemukvm + rllinker "qemukvm" 22 2 + + # copy the /etc/qemu-ifup script and enable extended rights for running + # the emulator and certain network commands via sudo + ln -sf ${PLUGINDIR}/ifup ${PLUGINCONFDIR}/ifup + ln -sf ${PLUGINDIR}/ifdown ${PLUGINCONFDIR}/ifdown + + cat >> /mnt/etc/sudoers << EOF +# allow to start and stop kvm services / load-/unload kvm modules +#ALL ALL=NOPASSWD: /etc/init.d/qemukvm +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/tunctl -t tap* +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap* +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/bin/ip link set dev tap* up +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/bin/ip addr add * dev tap* +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/udhcpd -S /tmp/qemukvm/*/udhcpd.conf +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/bin/cp /tmp/qemukvm/*/forwarding /proc/sys/net/ipv4/conf/tap*/forwarding +#ALL ALL=NOPASSWD: ${killall} udhcpd +EOF + fi +else + [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of 'qemukvm' plugin failed" +fi -- cgit v1.2.3-55-g7522