Simultaneous VMs from the same base box?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Simultaneous VMs from the same base box?

Nicholas Robinson-Wall
Hello,

I'm trying to work out how to start multiple concurrent VMs from the same base box. Is this possible? My experiments so far have been met with failure due to clashing NAT interface MACs.

My Vagrantfile looks like this:

 
Vagrant::Config.run do |config|

  config.vm.box = "squeeze64"

  config.vm.define :one do |one_config|
    one_config.vm.host_name = `whoami`.strip + "-vagrant-1"
  end

  config.vm.define :two do |two_config|
    two_config.vm.host_name = `whoami`.strip + "-vagrant-2"
  end

  #[ ... puppet provisioner snipped ... ]

end


When I try vagrant up, I get:
 
[one] Importing base box 'vagrant-mendeley-squeeze64'...
[one] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.

Guest Additions Version: 3.2.10
VirtualBox Version: 4.2.6
[one] Matching MAC address for NAT networking...
[one] Clearing any previously set forwarded ports...
[one] Forwarding ports...
[one] -- 22 => 2222 (adapter 1)
[one] Creating shared folders metadata...
[one] Clearing any previously set network interfaces...
[one] Booting VM...
[one] Waiting for VM to boot. This can take a few minutes.
[one] VM booted and ready for use!
[one] Setting host name...
[one] Mounting shared folders...
[one] -- v-root: /vagrant
[one] -- manifests: /tmp/vagrant-puppet/manifests
[one] -- v-pp-m0: /tmp/vagrant-puppet/modules-0
[one] Running provisioner: Vagrant::Provisioners::Puppet...
[ ... provisioner output snipped ... ]

[two] Importing base box 'vagrant-mendeley-squeeze64'...
[two] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.

Guest Additions Version: 3.2.10
VirtualBox Version: 4.2.6
[two] Matching MAC address for NAT networking...
[two] Clearing any previously set forwarded ports...
[two] Fixed port collision for 22 => 2222. Now on port 2200.
[two] Forwarding ports...
[two] -- 22 => 2200 (adapter 1)
[two] Creating shared folders metadata...
[two] Clearing any previously set network interfaces...
[two] Booting VM...
[two] Waiting for VM to boot. This can take a few minutes.
The VM failed to remain in the "running" state while attempting to boot.
This is normally caused by a misconfiguration or host system incompatibilities.
Please open the VirtualBox GUI and attempt to boot the virtual machine
manually to get a more informative error message.

If I try starting the VM in virtualbox the error message I get is VERR_SHARING_VIOLATION, due to the NAT interface on the second VM having the same mac address as the one on the first.

Given that my guest OS (Debian) can deal with the MAC address being different (after clearing out udev's rules) I tried setting config.vm.base_mac to nil, but was met with this error: 

* Base MAC address for eth0/NAT must be set. Contact box maintainer for more information.

Do I have to customise config.vm.base_mac per VM? Is there another way around this?

Regards,
Nick 
Reply | Threaded
Open this post in threaded view
|

Re: Simultaneous VMs from the same base box?

Nicholas Robinson-Wall
I figured this one out. I was too quick to jump to a conclusion about what VERR_SHARING_VIOLATION means. It turns out that virtualbox doesn't care about the MAC address on NAT interfaces being the same across separate boxes (and this is somewhat a fundamental requirement for vagrant to integrate with it). It was actually complaining that the IDE controller was trying to share the host DVD drive with multiple guests.

When you create a blank VM in virtualbox it prompts you to choose an ISO for the guest's DVD drive. If you impatiently click through this without choosing (I PXE booted the machine I turned into my base box) it maps the guest DVD drive to the host DVD drive, which can't be used by more than one VM at a time. If I'd used something like veewee to construct my base box I wouldn't have had a problem, but I have an existing customised PXE image which is used for both production servers and dev VMs and a cursory glance at the code made it look like significant effort to make it able to work with a netbooted machine so I opted to grab some of the cleanup scripts for my OS and just use them on a freshly installed machine.

-Nick

--