VirtualBox VM Error (NS_ERROR_FAILURE)

Problem:

I was recently tasked with devops project in which I needed to set up a local development virtual machine for a client. I ended up using the vagrant ‘ubuntu/xenial64’ to base the VM off of. After building the VM, I packaged it up using vagrant package and sent the .box file to a colleague to test it out. He received this error after trying to run vagrant up.

Bringing machine 'default' up with 'virtualbox' provider...

==> 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: Forwarding ports...
default: 8000 (guest) => 8888 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "b0f07baa-ff0d-4eaa-833a-0b379b9d02f2", "--type", "headless"]

Stderr: VBoxManage: error: The VM session was aborted
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface ISession.

Fix:

VirtualBox version: 5.1.18
Vagrant version: 1.9.2

Evidently the Ubuntu 16.04 base image (ubuntu/xenial) that vagrant uses pre-configures the VM to use a log file attached to a virtual serial port. If the directory for your log file mismatches when trying to run it on another machine (as it very likely will), then you’re going to get NS_ERROR_FAILURE. You would think that you could just disable the serial port entirely without issue.. but you would be wrong. The machine will just hang somewhere around here:

usbhid: USB HID core driver
random: nonblocking pool is initialized

What you actually need to do is disconnect the serial port.

Vagrant solution (Vagrantfile):

config.vm.provider "virtualbox" do |v|
  v.customize ["modifyvm", :id, "--uart1", "0x3f8", "4"]
  v.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
end

OR

VirtualBox solution (inside VM settings):