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):

How To Be A Good Developer: Humility

Stay humble.

There’s something I need to tell you.. and it may hurt. You might want to take a seat for this.. You’re not that good.

While perusing through a codebase or participating in some code review, there may be moments where you scratch your head and softly murmur “What the hell? Were they high when they wrote this?”. You should withhold your judgement for a several reasons:

-Take into account the timeline that this person was operating under. Perhaps they were under a tight deadline and had to hack things together.

-Maybe the overall design of the project forbids this person from taking a highly organized, engineered approach to their code.

-They had a skewed mental model of what actually needs to be accomplished. Communication can and does falter.

-You have a skewed mental model of what actually needs to be accomplished. Consider the possibility that you might be wrong.

-This person was potentially just having an off day. Humans make mistakes.

-It could be your code that you’re reading. Try not to be so hard on yourself 😉

Even if you feel you are the fabled 10x developer, time is the great equalizer. We will all be humbled before the project with the ridiculously short deadline. There comes a point where it’s a matter of shipping something vs shipping the perfect thing. Oftentimes that thing you’re obsessed with getting just right doesn’t matter in the grand scheme of things.