summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
diff options
context:
space:
mode:
authorDirk von Suchodoletz2009-08-19 10:34:28 +0200
committerDirk von Suchodoletz2009-08-19 10:34:28 +0200
commit4124137d36998c6aef7f73e6e9c756c288e673e2 (patch)
treea905e02dc7ebcdc973b0fecfc691d0381e75888b /os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
parentNo need to use the uclib-wrapper any more (see r3099). (diff)
downloadcore-4124137d36998c6aef7f73e6e9c756c288e673e2.tar.gz
core-4124137d36998c6aef7f73e6e9c756c288e673e2.tar.xz
core-4124137d36998c6aef7f73e6e9c756c288e673e2.zip
Heavily renovated qemukvm plugin (especially the networking part).
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@3101 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm')
-rw-r--r--os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm63
1 files changed, 47 insertions, 16 deletions
diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
index 54a91935..23a14924 100644
--- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
+++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
@@ -23,6 +23,7 @@ use File::Path;
use OpenSLX::Basics;
use OpenSLX::Utils;
+use OpenSLX::DistroUtils;
sub new
{
@@ -110,6 +111,7 @@ sub installationPhase
$self->{attrs} = $info->{'plugin-attrs'};
my $engine = $self->{'os-plugin-engine'};
+ my $pluginRepoPath = "$self->{pluginRepositoryPath}";
# Different names of the tool (should be unified somehow!?)
if (!isInPath('qemu-kvm') || !isInPath('kvm')) {
@@ -117,12 +119,56 @@ sub installationPhase
$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 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
+ # Copy the later /etc/qemu-ifup,down
copyFile("$self->{openslxBasePath}/lib/plugins/qemukvm/files/qemu-if*",
"$self->{pluginRepositoryPath}/");
+
+ my $initFile = newInitFile();
+ $initfile->setDesc("Setup environment for QEMU/KVM");
+ 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
+ echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding
+ echo "1" >/proc/sys/net/ipv4/conf/tap0/forwarding
+ End-of-Here
+ my $do_stop = unshiftHereDoc(<<' End-of-Here');
+ /opt/openslx/uclib-rootfs/usr/sbin/brctl delif br0 tap0
+ echo "0" >/proc/sys/net/ipv4/conf/br0/forwarding
+ echo "0" >/proc/sys/net/ipv4/conf/tap0/forwarding
+ End-of-Here
+
+ # add helper functions to initfile
+ # first parameter name of the function
+ # second parameter content of the function
+ $initFile->addFunction('do_start', $do_start);
+ $initFile->addFunction('do_stop', $do_stop);
+ $initFile->addFunction('do_restart', " : # do nothing here");
+
+ # 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;
}
@@ -146,21 +192,6 @@ sub checkStage3AttrValues
return;
}
-# Write the runlevelscript
-sub _writeRunlevelScript
-{
- my $self = shift;
- my $location = shift;
- my $file = shift;
- my $kind = shift;
-
- # should use the abstract write runlevel script way, see
- # http://lab.openslx.org/repositories/revision/openslx/2405 ff.
- my $runlevelScript = $self->{distro}->fillRunlevelScript($location, $kind);
-
- spitFile($file, $runlevelScript);
-}
-
# The bridge configuration needs the bridge module to be present in early
# stage3
sub suggestAdditionalKernelModules