Lately I’ve been doing some work in virtual machines built with Vagrant and noticed a strange thing: vagrant machine cannot start with no obvious error:

C:\Users\Boris\projects\homestead>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 => 8000 (adapter 1)
    default: 443 => 44300 (adapter 1)
    default: 3306 => 33060 (adapter 1)
    default: 5432 => 54320 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...    

Moreover, it will never end trying to connect. At first, it looked to me as if there was a networking issue. I tried to vagrant halt but the VM didn’t respond. For a moment, I thought that I should have done a full backup last night.

When trying to start the VM through Virtualbox interface I got this error:

Whoa.. no VT-x/AMD-V

So after a quick search I found out that this is a well-known issue in Virtualbox community:

I enabled Hyper-V several days ago when experimenting with Windows Unversal apps, and now it does not allow other types of virtualization to run. Virtualbox appears to have its own hypervisor thing that tries to get access to your hardware, and if you have Hyper-V running, you get a conflict. Too bad that vagrant can’t properly handle this error - its console log messages are misleading and somewhat alarming.

Looks like there is no other way to make Virtualbox and Hyper-V both work without needing a reboot. You cannot switch off hardware acceleration in Virtualbox VM once it has been created, so it leaves us the only option - restart a computer.

I created a couple of .bat following Mike Lichtenberg’s advice for now.

When I need to run a vagrant machine:

bcdedit /set hypervisorlaunchtype off

and when I need Hyper-V VMs:

bcdedit /set hypervisorlaunchtype auto

Note that these commands will need to be executed under admin privileges.