#!/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); }