summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Janczyk2010-04-06 20:01:24 +0200
committerMichael Janczyk2010-04-06 20:01:24 +0200
commite437b8813f2a84ccffa3a75ba1f534b38ce72b9c (patch)
treefcc8c42ec290da4f343797d4eee4c03087fd01df
parentAdding the runlevel linker again (having the upstart component for newer (diff)
downloadcore-e437b8813f2a84ccffa3a75ba1f534b38ce72b9c.tar.gz
core-e437b8813f2a84ccffa3a75ba1f534b38ce72b9c.tar.xz
core-e437b8813f2a84ccffa3a75ba1f534b38ce72b9c.zip
cumulative commit of local branch, many changes regarding virtualization
-rw-r--r--boot-env/OpenSLX/BootEnvironment/PXE.pm4
-rw-r--r--boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm14
-rwxr-xr-xboot-env/syslinux/extlinuxbin52714 -> 52294 bytes
-rwxr-xr-xinitramfs/stage3-stuff/bin/hwautocfg4
-rw-r--r--installer/OpenSLX/OSSetup/Engine.pm10
-rw-r--r--os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm101
-rw-r--r--os-plugins/plugins/qemukvm/XX_qemukvm.sh107
-rw-r--r--os-plugins/plugins/qemukvm/files/qemu-ifdown31
-rw-r--r--os-plugins/plugins/qemukvm/files/qemu-ifup59
-rw-r--r--os-plugins/plugins/qemukvm/files/run-virt.include282
-rwxr-xr-xos-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh20
-rw-r--r--os-plugins/plugins/vmchooser/files/run-virt.sh63
-rw-r--r--os-plugins/plugins/vmware/XX_vmware.sh9
-rw-r--r--os-plugins/plugins/vmware/files/run-virt.include10
-rw-r--r--os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm116
-rw-r--r--os-plugins/plugins/xen/XX_xen.sh54
-rw-r--r--os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh23
-rwxr-xr-xos-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh42
18 files changed, 634 insertions, 315 deletions
diff --git a/boot-env/OpenSLX/BootEnvironment/PXE.pm b/boot-env/OpenSLX/BootEnvironment/PXE.pm
index e49e52b6..d46786d0 100644
--- a/boot-env/OpenSLX/BootEnvironment/PXE.pm
+++ b/boot-env/OpenSLX/BootEnvironment/PXE.pm
@@ -81,6 +81,7 @@ sub writeBootloaderMenuFor
}
$info->{menuLabel} = $label;
}
+# if kernel=*xen* then run sub _xenLabel from xen.pm
my $slxLabels = '';
foreach my $info (sort { $a->{label} cmp $b->{label} } @$systemInfos) {
my $vendorOSName = $info->{'vendor-os'}->{name};
@@ -112,13 +113,14 @@ sub writeBootloaderMenuFor
$append .= " file=$bootURI" if length($bootURI);
$append .= " file=$tftpPrefix" if length($tftpPrefix);
$append .= " $clientAppend";
-
$slxLabels .= "LABEL openslx-$pxeLabel\n";
$slxLabels .= $pxeDefault;
$slxLabels .= "\tMENU LABEL ^$info->{menuLabel}\n";
$slxLabels .= "\tKERNEL $pxePrefix$vendorOSName/$kernelName\n";
$slxLabels .= "\tAPPEND $append\n";
$slxLabels .= "\tIPAPPEND 3\n";
+# if kernel=*xen* then run sub _xenBootEntry from xen.pm
+# if (!defined $xenKernel) {...}
my $helpText = $info->{description} || '';
if (length($helpText)) {
# make sure that text matches the given margin
diff --git a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
index ca4764ca..cac92b37 100644
--- a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
+++ b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
@@ -383,13 +383,21 @@ sub _writeSlxSystemConf
# check if default directories available and copy them to /etc
my $defaultDirConfig = "$self->{'root-path'}/etc/opt/openslx/openslx.conf";
my $configTargetPath = "$self->{'build-path'}/etc";
-
+ my $defaultConfVer = slurpFile("$defaultDirConfig");
+ my $actConfVer = "Version 0.2";
+
if (-r $defaultDirConfig) {
$self->addCMD("cp -p $defaultDirConfig $configTargetPath/");
+ if ($defaultConfVer =~ m{$actConfVer}) {
+ warn _tr(
+ "Your version of default dir file (openslx.conf) is to old!\n".
+ "Eventually the system won't work.\n" .
+ "Please run install, update or clone of this system again!\n");
+ }
} else {
die _tr(
- "No default directories defined!\n" .
- "Please run install, update or clone of this system again!\n");
+ "No default directories defined!\n" .
+ "Please run install, update or clone of this system again!\n");
}
return;
diff --git a/boot-env/syslinux/extlinux b/boot-env/syslinux/extlinux
index d97dd70c..69d8bf56 100755
--- a/boot-env/syslinux/extlinux
+++ b/boot-env/syslinux/extlinux
Binary files differ
diff --git a/initramfs/stage3-stuff/bin/hwautocfg b/initramfs/stage3-stuff/bin/hwautocfg
index 9cd0f8a4..fee54a16 100755
--- a/initramfs/stage3-stuff/bin/hwautocfg
+++ b/initramfs/stage3-stuff/bin/hwautocfg
@@ -29,7 +29,9 @@ echo "0 0 0 0" >/proc/sys/kernel/printk
echo "/sbin/mdev" >/proc/sys/kernel/hotplug
modprobe -a ${MODPRV} usbhid hid-bright 2>/dev/null &
nwcardlist=$(echo ${slxconf_listnwmod}|sed "s/\ /|/g")
-hwinfo --netcard --usb-ctrl | grep modprobe | grep -E "$nwcardlist|hcd" | \
+# save results for later info and for Xen plugin when starting Xen VM
+hwinfo --netcard --usb-ctrl >/etc/hwinfo.netcard-usbctrl
+grep modprobe /etc/hwinfo.netcard-usbctrl | grep -E "$nwcardlist|hcd" | \
grep -v ehci | sed 's/.* Cmd: "//;s/"//' | sort -u >/etc/modprobe.base
# virtio hack
if [ $(grep -ic "virtio_pci" /etc/modprobe.base) -ge 1 ]; then
diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm
index 4160b4b5..72e8c7e8 100644
--- a/installer/OpenSLX/OSSetup/Engine.pm
+++ b/installer/OpenSLX/OSSetup/Engine.pm
@@ -1106,8 +1106,9 @@ sub _generateDefaultDirs
my $OPENSLX_DEFAULT_DIR = "/opt/openslx";
my $OPENSLX_DEFAULT_CONFDIR = "/etc/opt/openslx";
my $OPENSLX_DEFAULT_LOGDIR = "/var/log/openslx";
- my $OPENSLX_DEFAULT_BINDIR = "/var/opt/openslx/bin";
- my $OPENSLX_DEFAULT_LIBDIR = "/var/opt/openslx/lib";
+ my $OPENSLX_DEFAULT_VARDIR = "/var/opt/openslx";
+ my $OPENSLX_DEFAULT_BINDIR = "$OPENSLX_DEFAULT_VARDIR/bin";
+ my $OPENSLX_DEFAULT_LIBDIR = "$OPENSLX_DEFAULT_VARDIR/lib";
my $OPENSLX_DEFAULT_VIRTDIR = "/var/lib/virt";
mkpath("$targetRoot/$OPENSLX_DEFAULT_DIR",
"$targetRoot/$OPENSLX_DEFAULT_CONFDIR",
@@ -1117,9 +1118,12 @@ sub _generateDefaultDirs
"$targetRoot/$OPENSLX_DEFAULT_VIRTDIR");
slxsystem("chmod 1777 $targetRoot/$OPENSLX_DEFAULT_LOGDIR");
- my $openslxConfig = "OPENSLX_DEFAULT_DIR=$OPENSLX_DEFAULT_DIR\n";
+ my $openslxConfig = "# Default OpenSLX directories defined by satge 1\n";
+ $openslxConfig .= "# Version 0.2\n\n";
+ $openslxConfig .= "OPENSLX_DEFAULT_DIR=$OPENSLX_DEFAULT_DIR\n";
$openslxConfig .= "OPENSLX_DEFAULT_CONFDIR=$OPENSLX_DEFAULT_CONFDIR\n";
$openslxConfig .= "OPENSLX_DEFAULT_LOGDIR=$OPENSLX_DEFAULT_LOGDIR\n";
+ $openslxConfig .= "OPENSLX_DEFAULT_VARDIR=$OPENSLX_DEFAULT_VARDIR\n";
$openslxConfig .= "OPENSLX_DEFAULT_BINDIR=$OPENSLX_DEFAULT_BINDIR\n";
$openslxConfig .= "OPENSLX_DEFAULT_LIBDIR=$OPENSLX_DEFAULT_LIBDIR\n";
$openslxConfig .= "OPENSLX_DEFAULT_VIRTDIR=$OPENSLX_DEFAULT_VIRTDIR\n";
diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
index ee4b3417..e4ef657f 100644
--- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
+++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
@@ -103,7 +103,7 @@ 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'};
@@ -111,8 +111,9 @@ sub installationPhase
$self->{attrs} = $info->{'plugin-attrs'};
my $engine = $self->{'os-plugin-engine'};
- my $pluginRepoPath = "$self->{pluginRepositoryPath}";
-
+ 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(
@@ -123,56 +124,92 @@ sub installationPhase
if (!isInPath('sudo')) {
$engine->installPackages($self->{distro}->getPackageName('sudo'));
}
- # Copy run-virt.include to the appropriate place for inclusion in stage4
- copyFile("$self->{openslxBasePath}/lib/plugins/qemukvm/files/run-virt.include",
- "$self->{pluginRepositoryPath}/");
- # Copy the later /etc/qemu-ifup,down
- copyFile("$self->{openslxBasePath}/lib/plugins/qemukvm/files/qemu-if*",
- "$self->{pluginRepositoryPath}/");
- chmod 0755, "$self->{pluginRepositoryPath}/qemu-ifup";
- chmod 0755, "$self->{pluginRepositoryPath}/qemu-ifdown";
+
+ # 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");
- $initFile->addToBlock('head','. /etc/opt/openslx/network.qemukvm');
+ # 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');
- # Adding 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
+ # 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');
- /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
+ 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 nothing here");
-
+ $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",
diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh
index a63af161..13c2b91e 100644
--- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh
+++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh
@@ -11,40 +11,56 @@
# 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 /initramfs/plugin-conf/qemukvm.conf ]; then
+if [ -e ${CONFFILE} ]; then
- # check for the virtualization CPU features
- if grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then
- [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module"
- elif grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then
- [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module"
- 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
- exit 1
- fi
- # load the tunnel device module
- modprobe tun 2>/dev/null
-
# load needed variables
- . /initramfs/plugin-conf/qemukvm.conf
+ . ${CONFFILE}
# Test if this plugin is activated... more or less useless with the
# new plugin system
- if [ $qemukvm_active -ne 0 ]; then
-
+ 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)
@@ -60,41 +76,42 @@ qemu(-kvm)\n makes not much sense." nonfatal
[ $DEBUGLEVEL -gt 1 ] && error " * Incomplete information in variable \
${qemukvm_imagesrc}." nonfatal
fi
- # copy version depending files - the vmchooser expects for every virtua-
- # lization plugin a file named after it (here run-qemukvm.include)
- testmkd /mnt/etc/opt/openslx/plugins/qemukvm
- cp /mnt/opt/openslx/plugin-repo/qemukvm/run-virt.include \
- /mnt/etc/opt/openslx/plugins/qemukvm/run-qemukvm.include
+
# 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" \
- >/mnt/etc/opt/openslx/plugins/qemukvm/network.qemukvm
+ >${PLUGINCONFDIR}/network.conf
# copy the runlevel script (proper place for all distros??)
- cp /mnt/opt/openslx/plugin-repo/qemukvm/qemukvm /mnt/etc/init.d
+ 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 /opt/openslx/plugin-repo/qemukvm/qemu-ifup /mnt/etc/qemu-ifup
- ln -sf /opt/openslx/plugin-repo/qemukvm/qemu-ifdown /mnt/etc/qemu-ifdown
- ln -sf /opt/openslx/plugin-repo/qemukvm/qemu-ifup /mnt/etc/kvm-ifup
- ln -sf /opt/openslx/plugin-repo/qemukvm/qemu-ifdown /mnt/etc/kvm-ifdown
+ ln -sf ${PLUGINDIR}/ifup ${PLUGINCONFDIR}/ifup
+ ln -sf ${PLUGINDIR}/ifdown ${PLUGINCONFDIR}/ifdown
- for qemubin in qemu kvm ; do
- qemu="$(binfinder ${qemubin})"
- [ -n "${qemu}" ] && \
- echo "ALL ALL=NOPASSWD: ${qemu}" >>/mnt/etc/sudoers
+ for qemubin in qemu-kvm kvm qemu ; do
+ qemu=$(binfinder ${qemubin})
+ [ -n "${qemu}" ] && echo "ALL ALL=NOPASSWD: ${qemu}" >>/mnt/etc/sudoers
done
- echo -e "#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/tunctl -t tap*\n\
-#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/ip addr add * dev tap*\n\
-#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap*\n\
-ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/udhcpd -S /tmp/qemu*\n\
-ALL ALL=NOPASSWD: killall udhcpd" >>/mnt/etc/sudoers
+ #killall=$(binfinder killall)
+ 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*
+# TODO: check if kvm / qemu sufficient
+#ALL ALL=NOPASSWD: ${killall} udhcpd
+#ALL ALL=NOPASSWD: ${PLUGINDIR}/ifup
+#ALL ALL=NOPASSWD: ${PLUGINDIR}/ifdown
+#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/udhcpd -S /tmp/qemukvm/if*
+#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/ip addr add * dev tap*
+EOF
fi
else
- [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of qemukvm plugin failed"
+ [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of 'qemukvm' plugin failed"
fi
diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifdown b/os-plugins/plugins/qemukvm/files/qemu-ifdown
deleted file mode 100644
index 8c52d76f..00000000
--- a/os-plugins/plugins/qemukvm/files/qemu-ifdown
+++ /dev/null
@@ -1,31 +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/
-# -----------------------------------------------------------------------------
-# qemu-ifup
-# - Script used for network cleanup of qemukvm in stage4
-# -----------------------------------------------------------------------------
-
-# Clean up script
-
-case "$1" in
- tap1)
- # Bringing down the dhcp server
- killall udhcpd 2>/dev/null
- #iptables -t nat -D POSTROUTING -o br0 -j MASQUERADE 2>/dev/null
- ;;
- tap2)
- # Bringing down the dhcp server
- killall udhcpd 2>/dev/null
- ;;
-esac
-
-# Produce a clean exit status
-exit 0
diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifup b/os-plugins/plugins/qemukvm/files/qemu-ifup
deleted file mode 100644
index 6a25ad29..00000000
--- a/os-plugins/plugins/qemukvm/files/qemu-ifup
+++ /dev/null
@@ -1,59 +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/
-# -----------------------------------------------------------------------------
-# qemu-ifup
-# - Script used for network setup of qemukvm in stage4
-# -----------------------------------------------------------------------------
-
-# Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX
-# environments via uclibc-wrapper.
-
-. /etc/opt/openslx/plugin-repo/qemukvm/network.qemukvm
-
-# 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
- tap0)
- # Adding the tap0 interface to the existing bridge configured in stage3
- # brctl addif br0 tap0
- ;;
- tap1)
- # Configuring DHCP on host tap1 interface and enable IP masquerading
- [ -d /tmp/qemu-$USER ] || mkdir -p /tmp/qemu-$USER
- # cut the last .NNN/MM from nataddress
- sed -e "s,NWIF,tap1,;s,/misc/,/qemu/," \
- -e "s,CNETWORK,${nataddress%.*},;s,PIDFILE,/tmp/qemu-$USER/udhcpd.pid," \
- -e "s,LEASEFILE,/tmp/qemu-$USER/udhcpd.leases," \
- /etc/opt/openslx/plugin-repo/qemukvm/udhcpd.conf \
- >/tmp/qemu-$USER/udhcpd.conf
- touch /tmp/qemu-$USER/udhcpd.leases
- # ip link set tap1 up
- # ip addr add 192.168.101.254/24 dev tap1
- sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \
- -S /tmp/qemu-$USER/udhcpd.conf
- # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
- ;;
- tap2)
- # Configuring DHCP on host tap2 interface
- [ -d /tmp/qemu-$USER ] || mkdir -p /tmp/qemu-$USER
- sed "s,NWIF,tap2,;s,/misc/,/qemu/,;s,USER,$USER,;s,CNETWORK,$hoaddress," \
- /etc/opt/openslx/udhcpd.qemukvm >/tmp/qemu-$USER/udhcpd.conf
- touch /tmp/qemu-$USER/udhcpd.leases
- # ip link set tap2 up
- # ip addr add 192.168.101.254/24 dev tap2
- sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \
- -S /tmp/qemu-$USER/udhcpd.conf
- ;;
-esac
-
-# Produce a clean exit status
-exit 0
-
diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include
index b1f76535..be7bc4fb 100644
--- a/os-plugins/plugins/qemukvm/files/run-virt.include
+++ b/os-plugins/plugins/qemukvm/files/run-virt.include
@@ -1,6 +1,7 @@
-# qemukvm.include
-#
-# Copyright (c) 2009 - OpenSLX GmbH
+# 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
@@ -9,36 +10,164 @@
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org
-#
-# Include script for running the QEMU/Linux KVM virtual machine on an OpenSLX
-# client via the run-virt.sh. The stuff is copied to /etc/opt/openslx/run-
-# qemukvm.include during stage3.
+# -----------------------------------------------------------------------------
+# 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 -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
-# include general configuration from vmchooser
-. /etc/opt/openslx/run-virt.include
+# 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
-permem=50
-mem=$(expr ${totalmem} / 100 \* ${permem})
VIRTCMDOPTS="${VIRTCMDOPTS} -m ${mem}"
# network adaptor alternatives: rtl8139, pcnet, e1000
-VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=pcnet"
+network_card=${network_card:=pcnet}
+VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,macaddr=${macaddr},model=${network_card}"
+# define net kind and apply script
+qemu_ifscr="script=${PLUGINDIRQK}/ifup,downscript=${PLUGINDIRQK}/ifdown"
case "${network_kind}" in
bridge*)
- VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap0"
+ VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapbridge${VM_ID},${qemu_ifscr}"
+ sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbridge${VM_ID} 2>/dev/null
+ sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapbridge${VM_ID} \
+ 2>/dev/null
+ ;;
+ NAT|nat)
+ VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapnat${VM_ID},${qemu_ifscr}"
+ sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbnat${VM_ID} 2>/dev/null
+ sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapnat${VM_ID} \
+ 2>/dev/null
;;
- nat|NAT)
- VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1"
+ hostonly|host-only)
+ VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=taphost${VM_ID},${qemu_ifscr}"
+ sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbhost${VM_ID} 2>/dev/null
+ sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 taphost${VM_ID} \
+ 2>/dev/null
;;
- hostonly)
- VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap2"
+ *)
+ 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
-#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0"
-VIRTCMDOPTS="${VIRTCMDOPTS} -fdb /var/lib/virt/vmchooser/loopimg/fd.img"
# if $floppy_0 from run-virt.include set then fdtest="TRUE"
fdtest=
fdtest=${floppy_0:+"TRUE"}
@@ -61,17 +190,116 @@ cdrom1=${cdtest:-"FALSE"}
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"
-# set the variables appropriately
-for tool in kvm qemu-kvm qemu; do
- VIRTCMD=$(which ${tool} 2>/dev/null)
- [ "x$VIRTCMD" != "x" ] && break
-done
-[ -z $VIRTCMD ] && { writelog "No qemu/kvm tool found."; exit 1; }
-VIRTCMD="sudo $VIRTCMD"
-VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab ${diskfile}"
+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 "No user space KVM found. Using slow QEMU emulation"
+ writelog "User space emulation:\t\t${VIRTCMD}"
+else
+ writelog "User space virtualization:\t${VIRTCMD}"
+ VIRTCMD="sudo $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
+VIRTCMD="$VIRTCMD"
+# vga std/cirrus/vmware?
+VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen ${diskfile}"
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
index 153cac68..396631c1 100755
--- 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
@@ -13,9 +13,13 @@
# (should be kept identical to the files of virtualbox and vmware plugins)
#############################################################################
+. /etc/openslx.conf
+
+CONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}
+testmkd ${CONFDIR}
+
# configuring dhcpd stub for virtual networks
-testmkd /mnt/etc/opt/openslx
-echo "
+cat > ${CONFDIR}/udhcpd.conf << EOF
# general udhcpd configuration file for virtual machines written by
# $0 during OpenSLX stage3 configuration
@@ -30,15 +34,15 @@ interface NWIF
offer_time 6000
# location of the leases file
-lease_file LEASEDIR/udhcpd.leases
+lease_file LEASEFILE
# location of the pid file
-pidfile PIDFILE/udhcpd.pid
+pidfile PIDFILE
-opt dns ${domain_name_servers}
+option dns ${domain_name_servers}
option subnet 255.255.255.0
-opt router CNETWORK.254
-opt wins CNETWORK.10
+option router CNETWORK.254
+option wins CNETWORK.10
option domain virtual.site ${domain_name}
# additional options known to udhcpd
@@ -53,4 +57,4 @@ option domain virtual.site ${domain_name}
#wins #lease
#ntpsrv #tftp
#bootfile
-" >/mnt/etc/opt/openslx/udhcpd.conf
+EOF
diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh
index 5733ee41..9bc31396 100644
--- a/os-plugins/plugins/vmchooser/files/run-virt.sh
+++ b/os-plugins/plugins/vmchooser/files/run-virt.sh
@@ -40,13 +40,14 @@ xml=$1
################################################################################
# File name of the image
-imagename=$(grep -io "<image_name param=.*\"" ${xml} | \
+imgname=$(grep -io "<image_name param=.*\"" ${xml} | \
awk -F "\"" '{ print $2 }')
case ${xml} in
/tmp/*)
# we do not need folder name as it is already included by vmchooser
- diskfile=$imagename
+ diskfile=$imgname
+ imgname=$(basename ${imgname})
;;
*)
# Path to the image
@@ -54,18 +55,25 @@ case ${xml} in
[ -z $imgpath ] && \
{ imgpath=$(readlink -f $xml); imgpath=${imgpath%/*.xml}; }
# Diskfile is file including absolute path to it
- diskfile=$imgpath/$imagename
+ diskfile=$imgpath/$imgname
;;
esac
+# TODO: change to new var vmpath, remove diskfile afterwards
+vmpath=$diskfile
[ -e $diskfile ] || { echo -e "\n\tImage file $diskfile not found!"; exit 1; }
# Short description of the image (as present in the vmchooser menu line)
-short_description=$(grep -o "short_description param=.*\"" ${xml} | \
+vm_name=$(grep -o "short_description param=.*\"" ${xml} | \
sed -e "s/&.*;/; /g" | awk -F "\"" '{print $2}')
# If ${short_description} not defined use ${image_name}
-short_description=${short_description:-"${image_name}"}
-displayname=${short_description}
+# if ${vm_name} not defined use ${imgname}
+vm_name=${vm_name:-"${imgname%.*}"}
+# define vm_shortname since vm_name can be very long
+vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g")
+displayname=${vm_name}
+# remove blanks
+vm_name=$(echo ${vm_name} | sed -e "s, ,-,g")
# Type of virtual machine to run
virt_mach=$(grep -o "virtualmachine param=.*\"" ${xml} | \
@@ -74,7 +82,7 @@ virt_mach=$(grep -o "virtualmachine param=.*\"" ${xml} | \
# Make a guess from the filename extension if ${virt_mach} is empty (not set
# within the xml file)
if [ -z ${virt_mach} ] ; then
- case "$(echo ${imagename##*.}|tr [A-Z] [a-z])" in
+ case "$(echo ${imgname##*.}|tr [A-Z] [a-z])" in
vmdk)
virt_mach="vmware"
;;
@@ -104,6 +112,9 @@ parallel=$(grep -io '<parport param=.*"' ${xml} | awk -F '"' '{ print $2 }')
# Declaration of default variables
###############################################################################
+# VM-ID static (0D)
+VM_ID="00"
+
# cpu cores
cpu_cores="${cpu_cores}"
@@ -114,9 +125,15 @@ totalmem=$(expr $(grep -i "memtotal" /proc/meminfo | awk '{print $2}') / 1024)
permem=60
mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4)
-# Configuring ethernet mac address: first four bytes are fixed (00:50:56:0D)
-# the last two bytes are taken from the first local network adaptor of the host
-# system
+# configuring ethernet mac address: first 3 bytes are fixed (00:50:56)
+# 4th byte is the VM-ID (0D)
+# last two bytes are taken from the bridge of the host
+# define one MAC per guest
+macguestpart="00:50:56:${VM_ID}"
+machostpart=$($(which ifconfig) br0 | grep br0 | sed -e "s/ //g" | \
+ awk -F ":" '{print $(NF-1)":"$NF}')
+macaddr=$(echo "${macguestpart}:${machostpart}" | tr [a-z] [A-Z])
+#TODO: remove when vmware modified
mac=$(/sbin/ifconfig eth0 | grep eth0 | sed -e "s/ //g" \
| awk -F ":" '{print $(NF-1)":"$NF}')
@@ -144,6 +161,10 @@ ide="TRUE"
scsi="FALSE"
hddrv="ide"
+# add rw share
+sharepath="${HOME}"
+sharename="home"
+
# Display resolution within the host system
hostres=$(xvidtune -show 2>/dev/null| grep -ve "^$")
xres=$(echo "${hostres}" | awk '{print $3}')
@@ -222,11 +243,11 @@ writelog ()
# Logo for console
cat <<EOL
-
- .----.--.--.-----.--.--.--.----.-----.
- | _| | | | | | | _|_ _|
- |__| |_____|__|__|\___/|__|__| |_|
-OpenSLX script for preparing virtual machine environment ...
+ __ __
+ .----.--.--.-----.___.--.--.|__|.----.| |_
+ | _| | | |___| | || || _|| _|
+ |__| |_____|__|__| \___/ |__||__| |____|
+ OpenSLX virtual machine environment preparation script ...
EOL
@@ -243,15 +264,17 @@ writelog "finished\n"
# Copy guest configuration (with added information) config.xml to be accessed
# via virtual floppy
# fixme -> to be changed (vmchooser adapts the file content!?)
-echo "Please fix the config.xml generation"
+#TODO: wozu echo?
+#echo "Please fix the config.xml generation"
cp ${xml} ${PLUGINCONFDIR}/fd-loop/config.xml
# Check if virtual machine container file exists
-filecheck
+#filecheck
# Get all virtual machine specific stuff from the respective include file
-if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include ] ; then
- . ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include
+if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-virt.include ] ; then
+ self=${virt_mach}
+ . ${PLUGINCONFROOT}/${virt_mach}/run-virt.include
# start a windowmanager for easier handling
# (expect problems /w windows opening in background /w vmware without wm)
for dm in xfwm4 metacity openbox blackbox kwin fvwm2 ; do
@@ -266,7 +289,7 @@ if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include ] ; then
fi
done
${VIRTCMD} ${VIRTCMDOPTS}
- writelog "Bye.\n"
+ writelog "Bye."
exit 0
else
writelog "Failed because of missing ${virt_mach} plugin."
diff --git a/os-plugins/plugins/vmware/XX_vmware.sh b/os-plugins/plugins/vmware/XX_vmware.sh
index cb8683f6..116561f6 100644
--- a/os-plugins/plugins/vmware/XX_vmware.sh
+++ b/os-plugins/plugins/vmware/XX_vmware.sh
@@ -12,6 +12,10 @@
# script is included from init via the "." load function - thus it has all
# variables and functions available
+# TODO:
+# configs nach /etc/opt/openslx/plugins/vmware
+# cp nach run-virt.include
+
# TODO: nvram,functions
# write /etc/vmware/config (if a non-standard location of vmware basedir is
# to be configured), /etc/init.d/vmware
@@ -159,9 +163,8 @@ ${vmware_imagesrc}." nonfatal
prefvmx.useRecommendedLockedMemSize = "TRUE"' | sed -e "s/^ *//" \
>/mnt/etc/vmware/config
- # copy version depending files - the vmchooser expects for every virtua-
- # lization plugin a file named after it (here run-vmware.include)
- cp ${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR}/run-vmware.include
+ # copy virtualization include files to config dir
+ cp ${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR}
# copy version depending files
cp ${PLUGINDIR}/${vmware_kind}/vmplayer ${BINDIR}/vmplayer
if [ -e ${PLUGINDIR}/${vmware_kind}/vmware ]; then
diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include
index 6328baab..dfd07a89 100644
--- a/os-plugins/plugins/vmware/files/run-virt.include
+++ b/os-plugins/plugins/vmware/files/run-virt.include
@@ -1,6 +1,6 @@
# run-virt.include
# -----------------------------------------------------------------------------
-# Copyright (c) 2009 - RZ Uni Freiburg
+# Copyright (c) 2009..2010 - RZ Uni Freiburg
# Copyright (c) 2009..2010 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
@@ -13,7 +13,7 @@
# -----------------------------------------------------------------------------
# run-virt.include
# - component for vmware/player of the vmchooser plugin run-virt.sh
-# -----------------------------------------------------------------------------
+################################################################################
# configuration writer functions
################################################################################
@@ -140,8 +140,8 @@ usb.generic.autoconnect = \"TRUE\"
sharedFolder0.present = \"TRUE\"
sharedFolder0.enabled = \"${shared_folder}\"
sharedFolder0.expiration = \"never\"
-sharedFolder0.guestName = \"Home\"
-sharedFolder0.hostPath = \"${HOME}\"
+sharedFolder0.guestName = \"${sharename}\"
+sharedFolder0.hostPath = \"${sharepath}\"
sharedFolder0.readAccess = \"TRUE\"
sharedFolder0.writeAccess = \"TRUE\"
sharedFolder.maxNum = \"1\"
@@ -451,5 +451,5 @@ writelog ""
################################################################################
# using the modified version of the wrapper script
-VIRTCMD=/var/opt/openslx/bin/vmplayer
+VIRTCMD="${OPENSLX_DEFAULT_BINDIR}/vmplayer"
VIRTCMDOPTS="${vmopt} ${conffile}"
diff --git a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm
index 5e500b49..8af752b4 100644
--- a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm
+++ b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm
@@ -59,24 +59,126 @@ sub getAttrInfo
End-of-Here
content_regex => qr{^(0|1)$},
content_descr => '1 means active - 0 means inactive',
- default => '1',
+ # set active to 0, later set specially created Xen system to 1
+ default => '0',
+ },
+ # attribute 'imagesrc' defines where we can find xen images
+ 'xen::imagesrc' => {
+ applies_to_systems => 1,
+ applies_to_clients => 1,
+ description => unshiftHereDoc(<<' End-of-Here'),
+ Where do we store our xen images? NFS? Filesystem?
+ End-of-Here
+ content_regex => qr{^(/|nfs://)},
+ content_descr => 'local path or URI or "-" (unset)',
+ default => undef,
+ },
+ # attribute 'tftpdir' defines TFTP dir for network boots /w NAT
+ 'xen::tftpdir' => {
+ applies_to_systems => 1,
+ applies_to_clients => 1,
+ description => unshiftHereDoc(<<' End-of-Here'),
+ Do you want to define a stage 4 TFTP dir for netwoork boots?
+ Needed to boot Xen via NFS, we only need the initramfs
+ Hint: Mount your TFTP ro via NFS to a local dir
+ End-of-Here
+ content_regex => qr{^(/)},
+ content_descr => 'local path or "-" (unset)',
+ default => undef,
},
};
}
+sub installationPhase
+{
+ my $self = shift;
+ my $info = shift;
+
+ $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'};
+ $self->{openslxBasePath} = $info->{'openslx-base-path'};
+
+ # Copy run-virt.include and template files to the appropriate place for
+ # inclusion in stage4
+ my $pluginName = $self->{'name'};
+ my $pluginBasePath =
+ "$self->{openslxBasePath}/lib/plugins/$pluginName/files";
+
+ foreach my $file ( qw( run-virt.include machine.include hvm.include ) ) {
+ copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/");
+ chmod 0644, "$self->{pluginRepositoryPath}/$file";
+ }
+
+ return;
+}
+
+sub removalPhase
+{
+ my $self = shift;
+ my $info = shift;
+
+ return;
+}
+
sub suggestAdditionalKernelModules
{
my $self = shift;
my $makeInitRamFSEngine = shift;
my @suggestedModules;
-
- # Xen needs bridge module and for SUSE 10.2 netloop other OS: to be checked
- if ($makeInitRamFSEngine->{'distro-name'} =~ m{^suse}i) {
- push @suggestedModules, qw( bridge netloop )
- }
-
+
+ # Xen needs bridge module, for guests xennet and maybe xenblk
+ # earlier versions needed netloop
+ push @suggestedModules, qw( bridge xennet xenblk );
+
return @suggestedModules;
}
+#sub _xenLabel
+#{
+# # set label for each Xen system
+# foreach my $info (@$systemInfos) {
+# if ($info->{xen::active} eq 1) {
+# my $label = $info->{label} || '';
+# if (!length($label) || $label eq $info->{name}) {
+# if ($info->{name} =~ m{^(.+)::(.+)$}) {
+# my $system = $1;
+# my $exportType = $2;
+# $label = $system . "-xen" . ' ' x (36-length($system))
+# . $exportType;
+# } else {
+# $label = $info->{name};
+# }
+# }
+# }
+# $info->{pxeLabel} = $label;
+# }
+# return $info; #???
+#}
+
+#sub _xenBootEntry
+#{
+# # Xen entries look different
+# # Example:
+# # KERNEL mboot.c32 vendor-os/xen.gz dom0_mem=128000 ---
+# # vendor-os/vmlinuz-xen debug=3 --- vendor-os/initramfs-1
+# # TODO: versionsort oder per attr?
+# if ($info->{xen::active} eq 1) {
+# my $xenKernel = slxsystem(ls /boot/xen* | sort | tail -n 1);
+# $append .= " file=$bootURI" if length($bootURI);
+# $append .= " file=$tftpPrefix" if length($tftpPrefix);
+# $append .= " $clientAppend";
+# $append .= " --- $pxePrefix$vendorOSName/$info->{'initramfs-name'}";
+# $slxLabels .= "LABEL openslx-$info->{'external-id'}-xen\n";
+# # $slxLabels .= $pxeDefault;
+# $slxLabels .= "\tMENU LABEL ^$info->{pxeLabel}\n";
+# $slxLabels .= "\tKERNEL mboot.c32\n";
+# $slxLabels .= "\tAPPEND $pxePrefix$vendorOSName/$xenKernel";
+# # $slxLabels .= " dom0_mem=128000";
+# $slxLabels .= " --- $pxePrefix$vendorOSName/$kernelName";
+# $slxLabels .= " --- $append\n";
+# $slxLabels .= "\tIPAPPEND 3\n";
+# }
+# return $slxLabels;
+#}
+
1;
diff --git a/os-plugins/plugins/xen/XX_xen.sh b/os-plugins/plugins/xen/XX_xen.sh
index ba2c4f00..af3f6cc4 100644
--- a/os-plugins/plugins/xen/XX_xen.sh
+++ b/os-plugins/plugins/xen/XX_xen.sh
@@ -14,16 +14,60 @@
# script is included from init via the "." load function - thus it has all
# variables and functions available
-if [ -e /initramfs/plugin-conf/xen.conf ]; then
- . /initramfs/plugin-conf/xen.conf
- if [ $xen_active -ne 0 ]; then
+# include default directories
+. /etc/openslx.conf
+
+CONFFILE=/initramfs/plugin-conf/xen.conf
+PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/xen
+PLUGINDIR=/mnt/${OPENSLX_DEFAULT_DIR}/plugin-repo/xen
+VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/xen
+
+# 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 [ $xen_active -ne 0 2>/dev/null ]; then
+
+ [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'xen' os-plugin ...";
+
+ # load general configuration
+ . /etc/initramfs-setup
+
+ # get source of xen image server (get type, server and path)
+ if strinstr "/" "${xen_imagesrc}" ; then
+ vbimgprot=$(uri_token ${xen_imagesrc} prot)
+ vbimgserv=$(uri_token ${xen_imagesrc} server)
+ vbimgpath="$(uri_token ${xen_imagesrc} path)"
+ fi
+ if [ -n "${vbimgserv}" ] ; then
+ # directory where qemu images are expected in
+ mnttarget=${VIRTDIR}
+ # mount the xen image source readonly (ro)
+ fsmount ${vbimgprot} ${vbimgserv} ${vbimgpath} ${mnttarget} ro
+ else
+ [ $DEBUGLEVEL -gt 1 ] && \
+ error " * Incomplete information in variable ${xen_imagesrc}." \
+ nonfatal
+ fi
+
+ # copy virtualization include files to config dir
+ testmkd ${PLUGINCONFDIR}
testmkd /mnt/var/log/xen
testmkd /mnt/var/run/xend
testmkd /mnt/var/run/xenstored
+ cp ${PLUGINDIR}/*.include ${PLUGINCONFDIR}
+ # copy ${CONFFILE} to ${PLUGINCONFDIR} just in case
+ cp ${CONFFILE} ${PLUGINCONFDIR}
+ # activate init files
+ # TODO: in xen-slx start
+ # increase loop devices for loop images
+ modprobe -q loop max_loop=64 >/tmp/xen.log 2>&1
rllinker "xendomains" 14 8
rllinker "xend" 13 9
-
- modprobe loop max_loop=64
fi
fi
diff --git a/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh b/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh
deleted file mode 100644
index 321b6a06..00000000
--- a/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-# configure Xen bridge xenbr0
-modprobe ${MODPRV} netloop
-local ipls
-local vifnum="0"
-local bridge="xenbr${vifnum}"
-local netdev="eth${vifnum}"
-local pdev="p${netdev}"
-local vdev="veth${vifnum}"
-local vif0="vif0.${vifnum}"
-# fixme: that is the mac address of main ethernet device
-local mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
-
-brctl addbr ${bridge}
-brctl stp ${bridge} off
-brctl setfd ${bridge} 0
-brctl addif ${bridge} ${vif0}
-for ipls in "${netdev} name ${pdev}" "${vdev} name ${netdev}" \
- "${pdev} down arp off" "${pdev} addr fe:ff:ff:ff:ff:ff" \
- "${netdev} addr ${mac} arp on" "${bridge} up" "${vif0} up" \
- "${pdev} up" "${netdev} up"; do
- ip link set ${ipls}
-done
-brctl addif ${bridge} ${pdev}
diff --git a/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh b/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh
deleted file mode 100755
index 7267969c..00000000
--- a/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/ash
-# 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
-#
-# XEN specific init hook to create a bridge on the active network interface
-#############################################################################
-
-# configure Xen bridge xenbr0 (would it be possible to make it just br0?)
-
-modprobe ${MODPRV} netloop
-local ipls
-local vifnum="0"
-local bridge="xenbr${vifnum}"
-local netdev="eth${vifnum}" # should be ${nwif}
-local pdev="p${netdev}"
-local vdev="veth${vifnum}"
-local vif0="vif0.${vifnum}"
-# fixme: that is the mac address of main ethernet device
-local mac=${macaddr}
-
-brctl addbr ${bridge}
-brctl stp ${bridge} off
-brctl setfd ${bridge} 0.000000000001
-brctl addif ${bridge} ${vif0}
-for ipls in "${netdev} name ${pdev}" "${vdev} name ${netdev}" \
- "${pdev} down arp off" "${pdev} addr fe:ff:ff:ff:ff:ff" \
- "${netdev} addr ${mac} arp on" "${netdev} addr ${mac} arp on" \
- "${bridge} up" "${vif0} up" "${pdev} up" ; do
- ip link set ${ipls}
-done
-brctl addif ${bridge} ${pdev}
-
-# fixme: sending back the variable to init does not work properly at the
-# moment
-nwif=${bridge}