diff options
Diffstat (limited to 'os-plugins/plugins/qemukvm')
| -rw-r--r-- | os-plugins/plugins/qemukvm/OpenSLX/Distro/Base.pm | 63 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/OpenSLX/Distro/Debian.pm | 43 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/OpenSLX/Distro/Suse.pm | 42 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/OpenSLX/Distro/Ubuntu.pm | 24 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 256 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/XX_qemukvm.sh | 112 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/files/ifdown | 34 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/files/ifup | 75 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/files/run-virt.include | 306 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/init-hooks/20-nw-bridge-config/bridge.sh | 30 | ||||
| -rwxr-xr-x | os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh | 60 |
11 files changed, 0 insertions, 1045 deletions
diff --git a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Base.pm b/os-plugins/plugins/qemukvm/OpenSLX/Distro/Base.pm deleted file mode 100644 index 1e3a9bfe..00000000 --- a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Base.pm +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2008 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# qemukvm/OpenSLX/Distro/Base.pm -# - provides base implementation of the Distro API for the qemukvm plugin. -# ----------------------------------------------------------------------------- -package qemukvm::OpenSLX::Distro::Base; - -use strict; -use warnings; - -our $VERSION = 1.01; # API-version . implementation-version - -use Scalar::Util qw( weaken ); - -use OpenSLX::Basics; -use OpenSLX::Utils; - -################################################################################ -### interface methods -################################################################################ -sub new -{ - my $class = shift; - my $self = {}; - return bless $self, $class; - -} - -sub initialize -{ - my $self = shift; - my $engine = shift; - weaken($self->{engine}); - # avoid circular reference between plugin and its engine - - return 1; -} - -sub fillRunlevelScript -{ - my $self = shift; - my $location = shift; - my $kind = shift; - - my $script = unshiftHereDoc(<<' End-of-Here'); - - # cpuvirt=$(grep -e "vmx|svm" /proc/cpuinfo) - # modprobe $cpuvirt - - End-of-Here - - return $script; -} - -1; diff --git a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Debian.pm b/os-plugins/plugins/qemukvm/OpenSLX/Distro/Debian.pm deleted file mode 100644 index 6e2cab9b..00000000 --- a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Debian.pm +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2008 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# qemukvm/OpenSLX/Distro/debian.pm -# - provides Debian-specific overrides of the Distro API for the qemukvm -# plugin. -# ----------------------------------------------------------------------------- -package qemukvm::OpenSLX::Distro::Debian; - -use strict; -use warnings; - -use base qw(qemukvm::OpenSLX::Distro::Base); - -use OpenSLX::Basics; -use OpenSLX::Utils; - -################################################################################ -### interface methods -################################################################################ - -sub fillRunlevelScript -{ - my $self = shift; - my $location = shift; - my $kind = shift; - - my $script = unshiftHereDoc(<<' End-of-Here'); - - # something into here ... - - End-of-Here - return $script; -} - -1; diff --git a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Suse.pm b/os-plugins/plugins/qemukvm/OpenSLX/Distro/Suse.pm deleted file mode 100644 index 719dae2b..00000000 --- a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Suse.pm +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (c) 2008 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# qemukvm/OpenSLX/Distro/Suse.pm -# - provides SUSE specific overrides of the distro API for the qemukvm -# plugin. -# ----------------------------------------------------------------------------- -package qemukvm::OpenSLX::Distro::Suse; - -use strict; -use warnings; - -use base qw(qemukvm::OpenSLX::Distro::Base); - -use OpenSLX::Basics; -use OpenSLX::Utils; - -################################################################################ -### interface methods -################################################################################ - -sub fillRunlevelScript -{ - my $self = shift; - my $location = shift; - my $kind = shift; - - my $script = unshiftHereDoc(<<' End-of-Here'); - - End-of-Here - - return $script; -} - -1; diff --git a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Ubuntu.pm b/os-plugins/plugins/qemukvm/OpenSLX/Distro/Ubuntu.pm deleted file mode 100644 index ac764d31..00000000 --- a/os-plugins/plugins/qemukvm/OpenSLX/Distro/Ubuntu.pm +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2008 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# qemukvm/OpenSLX/Distro/Ubuntu.pm -# - provides Ubuntu-specific overrides of the Distro API for the qemukvm -# plugin. -# ----------------------------------------------------------------------------- -package qemukvm::OpenSLX::Distro::Ubuntu; - -use strict; -use warnings; - -# inherit everything from Debian (as Ubuntu is based on it anyway) -use base qw(qemukvm::OpenSLX::Distro::Debian); - - -1; diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm deleted file mode 100644 index 14e5917f..00000000 --- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm +++ /dev/null @@ -1,256 +0,0 @@ -# Copyright (c) 2009..2010 - RZ Uni Freiburg -# Copyright (c) 2009..2010 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# qemukvm.pm -# - Declares necessary information for the qemukvm plugin -# ----------------------------------------------------------------------------- -package OpenSLX::OSPlugin::qemukvm; - -use strict; -use warnings; - -use base qw(OpenSLX::OSPlugin::Base); - -use File::Basename; -use File::Path; - -use OpenSLX::Basics; -use OpenSLX::Utils; -use OpenSLX::DistroUtils; - -sub new -{ - my $class = shift; - my $self = { - name => 'qemukvm', - }; - - return bless $self, $class; -} - -sub getInfo -{ - my $self = shift; - - return { - description => unshiftHereDoc(<<' End-of-Here'), - Module for enabling services for the Linux kvm using qemu for - IO on an OpenSLX stateless client. - End-of-Here - precedence => 70, - required => [ qw( desktop ) ], - }; -} - -sub getAttrInfo -{ - # Returns a hash-ref with information about all attributes supported - # by this specific plugin - my $self = shift; - - # This default configuration will be added as attributes to the default - # system, such that it can be overruled for any specific system by means - # of slxconfig. - return { - # attribute 'active' is mandatory for all plugins - 'qemukvm::active' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'qemukvm'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - # attribute 'imagesrc' defines where we can find qemukvm images - 'qemukvm::imagesrc' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - Where do we store our qemukvm images? NFS? Filesystem? - End-of-Here - #TODO: check if the input is valid - #content_regex => qr{^(0|1)$}, - content_descr => 'Allowed values: local path or URI', - default => '', - }, - # attribute 'bridge' defines if bridged network mode should be - # switched on - 'qemukvm::bridge' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - Should the bridging (direct access of the qemukvm clients - to the ethernet the host is connected to) be enabled - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => 'Allowed values: 0 or 1', - default => '1', - }, - - }; -} - -sub installationPhase -{ - my $self = shift; - my $info = shift; - - $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; - $self->{pluginTempPath} = $info->{'plugin-temp-path'}; - $self->{openslxBasePath} = $info->{'openslx-base-path'}; - $self->{openslxConfigPath} = $info->{'openslx-config-path'}; - $self->{attrs} = $info->{'plugin-attrs'}; - - my $engine = $self->{'os-plugin-engine'}; - my $pluginRepoPath = $info->{'plugin-repo-path'}; - my $openslxBasePath = $info->{'openslx-base-path'}; - - # Different names of the tool (should be unified somehow!?) - if (!isInPath('qemu-kvm') || !isInPath('kvm')) { - $engine->installPackages( - $engine->getInstallablePackagesForSelection('qemu-kvm') - ); - } - # Sudo is needed to get access to certain system network commands - if (!isInPath('sudo')) { - $engine->installPackages($self->{distro}->getPackageName('sudo')); - } - - # Copy run-virt.include and template files to the appropriate place for - # inclusion in stage4 - my $pluginName = $self->{'name'}; - my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName/files"; - foreach my $file ( qw( run-virt.include ifup ifdown ) ) { - copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); - } - chmod 0755, "$pluginRepoPath/ifup", "$pluginRepoPath/ifdown"; - - my $initFile = newInitFile(); - $initFile->setName("qemukvm"); - $initFile->setDesc("Setup environment for QEMU/KVM"); - - # TODO: default dirs als globale funktion anbieten - $initFile-> - addToBlock('head','. /etc/opt/openslx/plugins/qemukvm/network.conf'); - - # TODO: remove all runlevel links for qemu-kvm or kvm - my $kvm_module = unshiftHereDoc(<<' End-of-Here'); - # Figure out which module we need. - if grep -q ^flags.*\\\<vmx\\\> /proc/cpuinfo; then - module=kvm_intel - elif grep -q ^flags.*\\\<svm\\\> /proc/cpuinfo; then - module=kvm_amd - else - module=kqemu - fi - End-of-Here - - my $do_start = unshiftHereDoc(<<' End-of-Here'); - # loading kvm module - kvm_module - [ -n "${module}" ] && modprobe -q ${module} - # load the tunnel device module - modprobe -q tun - # TODO: maybe in the ifup-script better solution? - # configuring the tap0 interface to the existing bridge configured in stage3 - #for i in 0 1 2; do - # /opt/openslx/uclib-rootfs/sbin/tunctl -t tap${i} >/dev/null 2>&1 - # ip link set dev tap${i} up - #done - #/opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap0 - #ip addr add ${nataddress} dev tap1 - #ip addr add ${hoaddress} dev tap2 - #echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding - #echo "1" >/proc/sys/net/ipv4/conf/tap0/forwarding - # make /dev/fb0 writable for all - # TODO: maybe solve via group or udev, etc... - chmod 766 /dev/fb* - End-of-Here - - my $do_stop = unshiftHereDoc(<<' End-of-Here'); - kvm_module - [ -n "${module}" ] && modprobe -q -r ${module} - modprobe -q -r tun - # TODO: tun removed, so this is not necessary - #/opt/openslx/uclib-rootfs/usr/sbin/brctl delif br0 tap0 - #ip addr del ${nataddress} dev tap1 - #ip addr del ${hoaddress} dev tap2 - #echo "0" >/proc/sys/net/ipv4/conf/br0/forwarding - #echo "0" >/proc/sys/net/ipv4/conf/tap0/forwarding - chmod 760 /dev/fb* - End-of-Here - - my $do_restart = unshiftHereDoc(<<' End-of-Here'); - do_stop && do_start - End-of-Here - - # add helper functions to initfile - # first parameter name of the function - # second parameter content of the function - $initFile->addFunction('kvm_module', $kvm_module); - $initFile->addFunction('do_start', $do_start); - $initFile->addFunction('do_stop', $do_stop); - $initFile->addFunction('do_restart', $do_restart); - - # place a call of the helper function in the stop block of the init file - # first parameter name of the function - # second parameter name of the block - $initFile->addFunctionCall('do_start', 'start'); - $initFile->addFunctionCall('do_stop', 'stop'); - $initFile->addFunctionCall('do_restart', 'restart'); - - my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0]; - - # write qemukvm initfile to plugin path - spitFile( - "$pluginRepoPath/qemukvm", - getInitFileForDistro($initFile, ucfirst($distro)) - ); - return; -} - -sub removalPhase -{ - my $self = shift; - my $info = shift; - - return; -} - -sub checkStage3AttrValues -{ - my $self = shift; - my $stage3Attrs = shift; - my $vendorOSAttrs = shift; - #my @problems; - - #my $vmimg = $stage3Attrs->{'qemukvm::imagesrc'} || ''; - - return; -} - -# The bridge configuration needs the bridge module to be present in early -# stage3 -sub suggestAdditionalKernelModules -{ - my $self = shift; - my $makeInitRamFSEngine = shift; - - my @suggestedModules; - - push @suggestedModules, qw( bridge ); - - return @suggestedModules; -} - -1; diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh deleted file mode 100644 index 8a41ff3b..00000000 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ /dev/null @@ -1,112 +0,0 @@ -# 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 diff --git a/os-plugins/plugins/qemukvm/files/ifdown b/os-plugins/plugins/qemukvm/files/ifdown deleted file mode 100644 index e741d9ca..00000000 --- a/os-plugins/plugins/qemukvm/files/ifdown +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Copyright (c) 2009 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# ifdown -# - Script used for network cleanup of qemukvm in stage4 -# ----------------------------------------------------------------------------- - -# get VM_ID through tap name -VM_ID=$(echo $1 | grep -oE "0[0-4]$") -QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID} -touch /tmp/qemukvm/udhcpd.pids -chmod 666 tmp/qemukvm/udhcpd.pids - -case "$1" in - tapnat0*) - # kill udhcpd - cat ${QKTMPDIR}/udhcpd.pid >> /tmp/qemukvm/udhcpd-unused.pid - ;; - taphost0*) - # kill udhcpd - cat ${QKTMPDIR}/udhcpd.pid >> /tmp/qemukvm/udhcpd-unused.pid - ;; -esac - -# Produce a clean exit status -exit 0 diff --git a/os-plugins/plugins/qemukvm/files/ifup b/os-plugins/plugins/qemukvm/files/ifup deleted file mode 100644 index b3218798..00000000 --- a/os-plugins/plugins/qemukvm/files/ifup +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# Copyright (c) 2009..2010 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# ifup -# - Script used for network setup of qemukvm in stage4 -# ----------------------------------------------------------------------------- - -. /etc/opt/openslx/openslx.conf - -PLUGINCONFDIR=${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm - -# get VM_ID through tap name -VM_ID=$(echo $1 | grep -oE "0[0-4]$") -QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID} - -# Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX -# environments via uclibc-wrapper. -. ${PLUGINCONFDIR}/network.conf - -# Just decide by the virtual network device used which kind of connection -# should be set up (passed in $1): tap0 = bridge, tap1 = nat, tap2 = hostonly. -case "$1" in - tapbridge0*) - sudo ip link set dev $1 up - # TODO: forwarding?, where needed - echo "1" >${QKTMPDIR}/forwarding - sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/br0/forwarding - sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/$1/forwarding - ;; - tapnat0*) - # Configuring DHCP on host tapnat interface and enable IP masquerading - sudo ip addr add ${nataddress} dev $1 - sudo ip link set dev $1 up - # TODO: forwarding?, where needed - echo "1" >${QKTMPDIR}/forwarding - sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/br0/forwarding - sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/$1/forwarding - # TODO: we use here atatic address, maybe change later - sed -e "s,NWIF,$1,;s,CNETWORK,192.168.1${VM_ID}," \ - -e "s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ - -e "s,LEASEFILE,${QKTMPDIR}/udhcpd.leases," \ - ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf \ - >${QKTMPDIR}/udhcpd.conf - touch ${QKTMPDIR}/udhcpd.leases - sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ - -S ${QKTMPDIR}/udhcpd.conf - # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE - ;; - taphost0*) - # Configuring DHCP on host taphost interface - sudo ip addr add ${hoaddress} dev $1 - sudo ip link set dev $1 up - # TODO: forwarding?, where needed - echo "1" >${QKTMPDIR}/forwarding - sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/br0/forwarding - sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/$1/forwarding - sed -e "s,NWIF,$1,;s,USER,${USER},;s,CNETWORK,192.168.1${VM_ID}," \ - -e "s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ - -e "s,LEASEFILE,${QKTMPDIR}/udhcpd.leases," \ - ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf >${QKTMPDIR}/udhcpd.conf - touch ${QKTMPDIR}/udhcpd.leases - sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ - -S ${QKTMPDIR}/udhcpd.conf - ;; -esac - -exit 0 diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include deleted file mode 100644 index 02c70469..00000000 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ /dev/null @@ -1,306 +0,0 @@ -# run-virt.include -# ----------------------------------------------------------------------------- -# Copyright (c) 2009..2010 - RZ Uni Freiburg -# Copyright (c) 2009..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 -# ----------------------------------------------------------------------------- -# run-virt.include -# - Include script for running the QEMU/Linux KVM virtual machine on an -# OpenSLX client via the run-virt.sh or run-vmgrid.sh -################################################################################ - -################################################################################ -### Include general configuration -################################################################################ -if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/${self}/${self}.conf ]; then - . ${OPENSLX_DEFAULT_CONFDIR}/plugins/${self}/${self}.conf -else - writelog "Problems reading config file of ${self} plugin" - # TODO: exit wenn conf wichtig - #exit 1 -fi - -################################################################################ -### Declaration of default variables -################################################################################ - -PLUGINCONFQK="${PLUGINCONFROOT}/${self}" -PLUGINDIRQK=${OPENSLX_DEFAULT_DIR}/plugin-repo/${self} -# create TMPDIR for all users -mkdir -m 1777 /tmp/${self} 2>/dev/null -# TMPDIR -QKTMPDIR="/tmp/${self}/${USER}/${VM_ID}" -# define dirs and files which can be removed after exit, be carefull! -RMDIRS="${QKTMPDIR}" -rm -rf ${RMDIRS} 2>/dev/null -mkdir -m 1777 -p ${QKTMPDIR} 2>/dev/null -# vmpath is the path to the vm, here an image (img|qcow*|vmdk) -diskfile=${vmpath} - -# check the file type -if echo ${imgname} | grep -iE "img|qcow|vmdk" >/dev/null 2>&1; then - imgtype=$(echo ${imgname##*.} | tr [a-z] [A-Z]) -else - writelog "${imgname} is not a valid image type (img|qcow*|vmdk), exiting!" - exit 1 -fi - -# hot keys ALT+CTRL+SHIFT -VIRTCMDOPTS="${VIRTCMDOPTS} -alt-grab" - -# display name, remove blanks because of cmdline problems -displayname=$(echo ${displayname} | sed -e "s, ,-,g") -VIRTCMDOPTS="${VIRTCMDOPTS} -name ${displayname}" - -writelog "Directories:" -writelog "\tTMPDIR:\t\t\t$QKTMPDIR" -writelog "Diskimage:" -writelog "\tDisk type:\t\t$imgtype" -writelog "\tDisk file:\t\t$diskfile" - -################################################################################ -### Hardware checks -################################################################################ - -# memory part equal to vmware plugin -# percentage of memory to use for virtualbox in standard case -if [ -n "${forcemem}" ]; then - mem="${forcemem}" -else - permem=30 - if [ "${totalmem}" -ge "1600" ]; then - permem=40 - fi -# # check if /tmp is on harddisk -# if grep -qe "/dev/.* /tmp " /proc/mounts ; then -# permem=60 -# id44="1" -# # Hack, if more than 2,5G RAM use 40% of Ram and write vmem into Ram as well -# # (40% vmware | 40% confdir(vmem...) | 20% host -# # VMplayer 2+ issue -# # TODO: makes this sense for vbox? -# #if [ "${totalmem}" -ge "2500" ]; then -# #permem=40 -# #rmdir ${snapshotdir} -# #snapshotdirold=${snapshotdir} -# #snapshotdir=/dev/shm/${self}/${USER}/${VM_ID} -# #mkdir -p ${snapshotdir} -# #ln -sf ${snapshotdir} ${snapshotdirold} -# #fi -# fi - mem=$(expr ${totalmem} / 100 \* ${permem}) - if [ "${id44}" = "1" ]; then - memhost=$(expr ${totalmem} - ${mem}) - else - memhost=$(expr ${totalmem} - ${mem} - ${mem}) - fi - # static first - permem=50 - mem=$(expr ${totalmem} / 100 \* ${permem}) - if [ "${mem}" -lt "256" ] || [ "${memhost}" -lt "256" ]; then - writelog "Memory out of range: ${mem} MB (guest) / ${memhost} MB (host)!" - writelog "Min. 256 MB for host and guest!" - exit 1 - fi -fi - -VIRTCMDOPTS="${VIRTCMDOPTS} -m ${mem}" - -# network adaptor alternatives: rtl8139, pcnet, e1000 -network_card=${network_card:=pcnet} -VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,macaddr=${macaddr},model=${network_card}" - -# define net kind and apply script -qemu_ifscr="script=${PLUGINCONFQK}/ifup,downscript=${PLUGINCONFQK}/ifdown" -case "${network_kind}" in - bridge*) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapbridge${VM_ID},${qemu_ifscr}" - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbridge${VM_ID} -u ${USER} \ - >/dev/null 2>&1 - sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapbridge${VM_ID} - POSTRUN="/opt/openslx/uclib-rootfs/sbin/tunctl -d tapbridge${VM_ID}" - ;; - nat) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapnat${VM_ID},${qemu_ifscr}" - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapnat${VM_ID} -u ${USER} \ - >/dev/null 2>&1 - sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapnat${VM_ID} - POSTRUN="/opt/openslx/uclib-rootfs/sbin/tunctl -d tapnat${VM_ID}" - ;; - host*) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=taphost${VM_ID},${qemu_ifscr}" - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t taphost${VM_ID} -u ${USER} \ - >/dev/null 2>&1 - sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 taphost${VM_ID} - POSTRUN="/opt/openslx/uclib-rootfs/sbin/tunctl -d taphost${VM_ID}" - ;; - *) - network_kind="user" - VIRTCMDOPTS="${VIRTCMDOPTS} -net user" - ;; -esac - -# translate boot, use if set else set to HardDisk -if [ -n "${boot}" ]; then - case ${boot} in - n*) # usually support for a,c,d,n, stands for Floppy, HD, CD-ROM, Network - boot="n" - # TODO: does not work yet, can be removed if tap1 solution better - if [ "${network_kind}" = "user" ] && [ -n "${virtualbox_tftpdir}" ]; then - VIRTCMDOPTS="${VIRTCMDOPTS},tftp=${virtualbox_tftpdir}" - fi - ;; - # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM - *) - boot="c" - ;; - esac -else - boot="c" -fi - -# external GUI port -vncport="590${VM_ID}" - -# TODO: most of the following does not make much sense yet ... -# virtual fd/cd/dvd and drive devices, floppy b: for configuration -# if $floppy_0 from run-virt.include set then fdtest="TRUE" -fdtest= -fdtest=${floppy_0:+"TRUE"} -# if $fdtest not set floppy0="FALSE", else "TRUE" -floppy0=${fdtest:-"FALSE"} -floppy1="TRUE" -floppy1name="/var/lib/virt/vmchooser/loopimg/fd.img" -# if $cdrom_0 from run-virt.include set then cdtest="TRUE" -cdtest= -cdtest=${cdrom_0:+"TRUE"} -# if $cdtest not set cdrom0="FALSE", else "TRUE" -cdrom0=${cdtest:-"FALSE"} -# if $cdrom_1 from run-virt.include set then cdtest="TRUE" -cdtest= -cdtest=${cdrom_1:+"TRUE"} -# if $cdtest not set cdrom1="FALSE", else "TRUE" -cdrom1=${cdtest:-"FALSE"} -# ide is expected default, test for the virtual disk image type should -# be done while creating the runscripts ... -ide="TRUE" -hddrv="ide" - -# TODO: nur bei vmchooser -#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0" -#VIRTCMDOPTS="${VIRTCMDOPTS} -fdb ${floppy1name}" - -# audio -VIRTCMDOPTS="${VIRTCMDOPTS} -soundhw all" - -# serial -#VIRTCMDOPTS="${VIRTCMDOPTS} -serial /dev/ttyS0" - -writelog "Virtual Hardware:" -writelog "\tGuest RAM:\t\t${mem} MB" -# echo nur wenn memhost gesetzt -[ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" -writelog "\tMAC address:\t\t$macaddr" -writelog "\tNetwork card:\t\t${network_card}" -writelog "\tNetwork kind:\t\t${network_kind}" -#writelog "\tCD-ROM1:\t${cdrom0}" -#writelog "\tCD-ROM2:\t${cdrom1}" -#writelog "\tFloppy_A:\t${floppy0}" -#writelog "\tFloppy_B:\t${floppy1}" -#writelog "\tShared Folders 'home':\t/home/${USER}" - -################################################################################ -### finally set env for run-virt.sh -################################################################################ - -# TODO: besser drive statt hda? -#-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] -# [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] -# [,cache=writethrough|writeback|none][,format=f][,serial=s] -# [,boot=on|off] -#-snapshot write to temporary files instead of disk image files -#-usb enable the USB driver (will be the default soon) -#-usbdevice name add the host or guest USB device 'name' -#-nographic disable graphical output and redirect serial I/Os to console -#-vga [std|cirrus|vmware|none] select video card type -#-vnc display start a VNC server on display -#-tftp dir allow tftp access to files in dir [-net user] -#-bootp file advertise file in BOOTP replies -#-no-fd-bootchk disable boot signature checking for floppy disks -#-no-acpi disable ACPI -#-kernel bzImage use 'bzImage' as kernel image -#-append cmdline use 'cmdline' as kernel command line -#-initrd file use 'file' as initial ram disk -#-serial dev redirect the serial port to char device 'dev' -#-parallel dev redirect the parallel port to char device 'dev' -#-monitor dev redirect the monitor to char device 'dev' -#-pidfile file write PID to 'file' -#-d item1,... output log to /tmp/qemu.log (use -d ? for a list of log items) -#-L path set the directory for the BIOS, VGA BIOS and keymaps -#-bios file set the filename for the BIOS -#-no-kvm disable KVM hardware virtualization -#-enable-nesting enable support for running a VM inside the VM (AMD only) -#-no-reboot exit instead of rebooting -#-no-shutdown stop before shutdown -#-loadvm [tag|id] -# start right away with a saved state (loadvm in monitor) -#-daemonize daemonize QEMU after initializing -#-kvm-shadow-memory megs set the amount of shadow pages to be allocated -#-mem-path set the path to hugetlbfs/tmpfs mounted directory, also -# enables allocation of guest memory with huge pages -#-mem-prealloc toggles preallocation of -mem-path backed physical memory -# at startup. Default is enabled. -#-option-rom rom load a file, rom, into the option ROM space -#-localtime set the real time clock to local time [default=utc] -#-startdate select initial date of the clock -#-icount [N|auto] -# enable virtual instruction counter with 2^N clock ticks per instruction -#-echr chr set terminal escape character instead of ctrl-a -#-virtioconsole c -# set virtio console -#-show-cursor show cursor - -# check for kvm modules -if [ -c /dev/kvm ]; then - for tool in kvm qemu-kvm; do - VIRTCMD=$(which ${tool} 2>/dev/null) - [ -n "$VIRTCMD" ] && break - done -else - VIRTCMD=$(which qemu 2>/dev/null) - writelog "KVM available but /dev/kvm not found!" - writelog "Trying fallback to QEMU emulation." -fi - -if [ -z "${VIRTCMD}" ]; then - writelog "No QEMU/KVM found, exiting!" - rm -rf ${RMDIRS} - exit 1 -elif [ "${VIRTCMD##*/}" = "qemu" ]; then - writelog "User space emulation:\t\t${VIRTCMD}" -else - writelog "User space virtualization:\t${VIRTCMD}" -fi - -# using snapshots -VIRTCMDOPTS="${VIRTCMDOPTS} -snapshot" - -# TODO: boot als var, -boot n, tftp... -VIRTCMDOPTS="${VIRTCMDOPTS} -boot c" - -# set headless mode -# define first, you do not want VIRTCMDOPTS from graphical start -VIRTCMDHL=${VIRTCMD} -VIRTCMDOPTSHL="${VIRTCMDOPTS} -nographic ${diskfile}" - -# graphical start -# vga std/cirrus/vmware? -#VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen ${diskfile}" -VIRTCMDOPTS="${VIRTCMDOPTS} ${diskfile}" diff --git a/os-plugins/plugins/qemukvm/init-hooks/20-nw-bridge-config/bridge.sh b/os-plugins/plugins/qemukvm/init-hooks/20-nw-bridge-config/bridge.sh deleted file mode 100644 index ccae3381..00000000 --- a/os-plugins/plugins/qemukvm/init-hooks/20-nw-bridge-config/bridge.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Copyright (c) 2009 - OpenSLX GmbH -# -# This program 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 -# -# Init hook to create a bridge on the active network interface -# (should be kept identical to the files of virtualbox and vmware plugins) -############################################################################# - -local bridge=br0 -local brnwif=${nwif} -local nwifmac=${macaddr} - -# bridge 0 already defined or some other problem -brctl addbr ${bridge} || exit 0 -brctl stp ${bridge} 0 -brctl setfd ${bridge} 0.000000000001 -ip link set addr ${nwifmac} ${bridge} -ip link set dev ${nwif} up -brctl addif ${bridge} ${nwif} - -# fixme: sending back the variable to init does not work properly at the -# moment -nwif=${bridge} diff --git a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh deleted file mode 100755 index b4f02389..00000000 --- a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Copyright (c) 2010 - OpenSLX GmbH -# -# This program 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 -# -# Init hook to create a bridge on the active network interface -# (should be kept identical in vmware, virtualbox and qemukvm plugins) -############################################################################# - -. /etc/openslx.conf - -CONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR} -testmkd ${CONFDIR} - -# configuring dhcpd stub for virtual networks -cat > ${CONFDIR}/udhcpd.conf << EOF -# general udhcpd configuration file for virtual machines written by -# $0 during OpenSLX stage3 configuration - -# start and end of the IP lease block -start CNETWORK.20 -end CNETWORK.100 - -# interface that udhcpd will use -interface NWIF - -# how long an offered address is reserved (leased) in seconds -offer_time 6000 - -# location of the leases file -lease_file LEASEFILE - -# location of the pid file -pidfile PIDFILE - -option dns ${domain_name_servers} -option subnet 255.255.255.0 -option router CNETWORK.1 -option wins CNETWORK.10 -option domain virtual.site ${domain_name} - -# additional options known to udhcpd -#subnet #timezone -#router #timesvr -#namesvr #dns -#logsvr #cookiesvr -#lprsvr #bootsize -#domain #swapsvr -#rootpath #ipttl -#mtu #broadcast -#wins #lease -#ntpsrv #tftp -#bootfile -EOF |
