I was using those commands for VirtualBox in rc.local, and I ran into the same problem. I don’t if this is the right way to do this, but it works for me.I created /Library/LaunchDaemons/local.localhost.startup.plist containing the code below. It runs the rc.local script once at start up.
launchctl load -w /Library/LaunchDaemons/local.localhost.startup