One places such information into a file which you point to with the environment variable "MTOOLSRC". +Below are some Perl functions to use the above tools: + + + ##################################################### + # + # VM Universe code for VmWare + # + # Initializing the VM for a job and accessing the + # results are done by including a suitable second + # VmWare disk. This disk is created for dynamic + # allocation and created in a VM which can use fdisk + # to create a fat32 partition and must have an + # mkfs which allows a "-t vfat" to complete creation + # of the disk. + # + # Once one has this disk it can be used as a template + # second drive for any VmWare VM. Note keep the core + # empty disk and copy it when needed as it gets + # larger with every use. + # + # We rely on "mtools" and "qemu" for the rest. + # "qemu-img" is used to convert the disk back and forth + # between vmdk and raw formats. "mcopy, mdir etc" + # are used to place and fetch files off the raw + # disk. + # + ##################################################### + + sub VMwareAddFile + { + my $file = shift; + runcmd("mcopy $file n:"); + runcmd("mdir n:"); + } + + sub VMwareFetchByPattern + { + my $pattern = shift; + runcmd("mcopy n:\*$pattern* ."); + runcmd("mdir n:"); + } + + sub VMwareRemakeDataDisk + { + my $data = shift; + my $raw = shift; + + my $cmd = "qemu-img convert -f raw $raw -O vmdk $data"; + runcmd($cmd); + } + + sub VMwareCreateRawDisk + { + my $empty = shift; + my $raw = shift; + + my $cmd = "qemu-img convert -f vmdk $empty -O raw $raw"; + runcmd($cmd); + } + + sub VMwareCreateMTOOLSRC + { + my $rawdisk = shift; + my $top = getcwd(); + my $baseentry = "drive n: file=\"$top/$rawdisk\" offset=32256 mtools_skip_check=1"; + print "Making MTOOLSRC here<$top>\n"; + open(MTRC,">$top/mtoolsrc") or die "Can not open mtoolsrc in <$top>:$!\n"; + print MTRC "$baseentry\n"; + close(MTRC); + $ENV{MTOOLSRC} = "$top/mtoolsrc"; + runcmd("mdir n:"); + } + Below is a suitable script for mounting a second disk at the right run level and deciding if a job should be run or the VM simply brought up for changes or inspection. @@ -123,4 +196,3 @@ close(JOB); print "Copy results back to /vmjob\n"; system("cp *.log /vmjob"); -[