From: Peter Dinda Date: Thu, 8 Aug 2013 00:37:11 +0000 (-0500) Subject: Configuration Generation tool for Linux Embedding X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=ad3742eacaa083b5fabcec9f360f62e9dbabf877 Configuration Generation tool for Linux Embedding This attempts to wrap the complexity of memory configuration, devmem, etc to tune to the user's environment and to their needs --- diff --git a/v3_config.pl b/v3_config.pl new file mode 100755 index 0000000..d6b6b35 --- /dev/null +++ b/v3_config.pl @@ -0,0 +1,243 @@ +#!/usr/bin/perl -w + + +print <$maxalloc && !powerof2($memblocksize)); +} + +$mem = 1024; + +print "How much memory (in MB) do you want to initially allocate for Palacios? [$mem] : "; +$mem = get_user($mem); + +$devmem='y'; + +print "Do you need userspace access to your VMs' physical memory? [$devmem] : "; +$devmem = get_user($devmem); + +print <ENV"); +print ENV "export PATH=\$PATH:$pdir/linux_usr\n"; +close(ENV); +`chmod 644 ENV`; + +print "Writing ./v3_init\n"; +open(INIT,">v3_init"); +print INIT "#!/bin/sh\n"; +print INIT "source $pdir/ENV\n"; # just in case + +print INIT "\n\n# insert the module\n"; +$cmd = "insmod $pdir/v3vee.ko"; +$cmd.= " allow_devmem=1 " if $devmem eq 'y'; +$cmd.= " options=\"mem_block_size=$memblocksize\" " if $override_memblocksize eq 'y'; +print INIT $cmd, "\n"; + +$cmd = "v3_mem"; +$cmd.= " -k " if $hotremove eq 'n'; +$cmd.= " -l " if $shadow eq 'y'; + +$chunk = $memblocksize / (1024 * 1024) ; +$numchunks = $mem / $chunk; +for ($i=0;$i<$numchunks;$i++) { + print INIT "$cmd $chunk\n"; +} +close(INIT); +`chmod 755 v3_init`; + +print "Writing ./v3_deinit\n"; +open(DEINIT,">v3_deinit"); +print DEINIT "#!/bin/sh\n"; +print DEINIT "echo WARNING - THIS DOES NOT CURRENTLY ONLINE MEMORY\n"; +print DEINIT "rmmod v3vee\n"; +close(DEINIT); +`chmod 755 v3_deinit`; +print "Done.\n"; + + + +sub get_user { + my $def = shift; + + my $inp = ; chomp($inp); + + if ($inp eq "") { + return $def; + } else { + return $inp; + } +} + +sub get_kernel_feature { + my $dir=shift; + my $feature=shift; + my $x; + + $x=`grep $feature $dir/config-\`uname -r\``; + + if ($x=~/^\s*\#/) { + return undef; + } else { + if ($x=~/\s*$feature\s*=\s*(\S*)\s*$/) { + return $1; + } else { + return undef; + } + } +} + +sub get_palacios_core_feature { + my $dir=shift; + my $feature=shift; + my $x; + + $x=`grep $feature $dir/.config`; + + if ($x=~/^\s*\#/) { + return undef; + } else { + if ($x=~/\s*$feature\s*=\s*(\S*)\s*$/) { + return $1; + } else { + return undef; + } + } +} + + +sub powerof2 { + my $x = shift; + my $exp; + + $exp = log($x) /log(2); + + return $exp==int($exp); +}