6 Welcome. The purpose of this tool is to simplify configuration
7 of the V3VEE environment on a Linux system. It assumes you
8 have already built Palacios, the Linux embedding, and the Linux
9 user-sapce tools. If you haven't, hit CTRL-C now and do the
10 at least the following:
21 This tool will create (or overwrite) the following for you:
23 ./ENV An environment file that you can source
24 ./v3_init A script that will insert Palacios with
25 relevant options and with appropriate memory
27 ./v3_deinit A script that will free memory and remove
30 After these are created, you can insert Palacio in the following way:
35 Then create and run VMs:
37 v3_create image_file name
42 And you can remove Palacios and free memory it is using.
47 We begin with a set of questions.
52 $pdir = `pwd`; chomp($pdir);
54 print "What is your Palacios directory? [$pdir] : ";
56 $pdir = get_user($pdir);
60 print "Where are your Linux kernel config files? [$kdir] : ";
62 $kdir = get_user($kdir);
64 $hotremove = get_kernel_feature($kdir, "CONFIG_MEMORY_HOTREMOVE");
66 if (!defined($hotremove)) {
70 $canhotremove=$hotremove;
72 $memblocksize = get_palacios_core_feature($pdir,"V3_CONFIG_MEM_BLOCK_SIZE");
74 if (!defined($memblocksize)) {
75 print "Cannot determine your memory block size from your Palacios configuration.\n";
79 if (!powerof2($memblocksize)) {
80 print "Cannot handle a memory block size that is not a power of two ($memblocksize)...\n";
84 $compmemblocksize = $memblocksize;
88 print "What is your kernel's maximum contiguous page allocation size in bytes (typicaly (MAX_ORDER-1)*4096) [$maxalloc] : ";
90 $maxalloc = get_user($maxalloc);
94 print "Do you need to run guests with shadow paging or for other reasons that require 4GB enforcement of page allocation? [$shadow] : ";
96 $shadow = get_user($shadow);
98 if ($hotremove eq "y") {
99 print "Your kernel supports hot remove. Do you want to use it? [$hotremove] : ";
100 $hotremove = get_user($hotremove);
104 $override_memblocksize = 'n';
106 if ($hotremove eq "n") {
108 $override_memblocksize = 'y';
109 print "You are not using hot-remove, so we will adjust memory block size\n";
110 print "Desired memory block size? [$maxalloc or less, power of 2] : ";
111 $memblocksize = get_user($maxalloc);
112 } while ($memblocksize>$maxalloc && !powerof2($memblocksize));
117 print "How much memory (in MB) do you want to initially allocate for Palacios? [$mem] : ";
118 $mem = get_user($mem);
122 print "Do you need userspace access to your VMs' physical memory? [$devmem] : ";
123 $devmem = get_user($devmem);
128 Palacios Direcotry: $pdir
129 Kernel Configs Directory: $kdir
130 Initial Palacios Memory (MB) $mem
131 Can Hot Remove: $canhotremove
132 Will Hot Remove: $hotremove
133 Enforce 4 GB Limit: $shadow
134 Compiled Memory Block Size: $compmemblocksize
135 Override Memory Block Size: $override_memblocksize
136 Actual Memory Block Size: $memblocksize
137 Allow Devmem: $devmem
147 print "Writing ./ENV\n";
149 print ENV "export PATH=\$PATH:$pdir/linux_usr\n";
153 print "Writing ./v3_init\n";
154 open(INIT,">v3_init");
155 print INIT "#!/bin/sh\n";
156 print INIT "source $pdir/ENV\n"; # just in case
158 print INIT "\n\n# insert the module\n";
159 $cmd = "insmod $pdir/v3vee.ko";
160 $cmd.= " allow_devmem=1 " if $devmem eq 'y';
161 $cmd.= " options=\"mem_block_size=$memblocksize\" " if $override_memblocksize eq 'y';
162 print INIT $cmd, "\n";
165 $cmd.= " -k " if $hotremove eq 'n';
166 $cmd.= " -l " if $shadow eq 'y';
168 $chunk = $memblocksize / (1024 * 1024) ;
169 $numchunks = $mem / $chunk;
170 for ($i=0;$i<$numchunks;$i++) {
171 print INIT "$cmd $chunk\n";
176 print "Writing ./v3_deinit\n";
177 open(DEINIT,">v3_deinit");
178 print DEINIT "#!/bin/sh\n";
179 print DEINIT "echo WARNING - THIS DOES NOT CURRENTLY ONLINE MEMORY\n";
180 print DEINIT "rmmod v3vee\n";
182 `chmod 755 v3_deinit`;
190 my $inp = <STDIN>; chomp($inp);
199 sub get_kernel_feature {
204 $x=`grep $feature $dir/config-\`uname -r\``;
209 if ($x=~/\s*$feature\s*=\s*(\S*)\s*$/) {
217 sub get_palacios_core_feature {
222 $x=`grep $feature $dir/.config`;
227 if ($x=~/\s*$feature\s*=\s*(\S*)\s*$/) {
240 $exp = log($x) /log(2);
242 return $exp==int($exp);