sandstorm-io / sandstorm

Sandstorm is a self-hostable web productivity suite. It's implemented as a security-hardened web app package manager.
https://sandstorm.io
Other
6.76k stars 705 forks source link

Can't run without VT-x #1959

Open techtonik opened 8 years ago

techtonik commented 8 years ago
$ vagrant-spk vm up
Calling 'vagrant' 'up' in /home/techtonik/p/roundup/.sandstorm
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'sandstorm/debian-jessie64' is up to date...
==> default: Setting the name of the VM: roundup_sandstorm_1462898506
==> 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: 6080 (guest) => 6080 (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", "b0467d24-2c46-4a64-9642-e1f98017faea", "--type", "headless"]

Stderr: VBoxManage: error: VT-x is not available (VERR_VMX_NO_VMX)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

Traceback (most recent call last):
  File "/usr/local/bin/vagrant-spk", line 834, in <module>
    main()
  File "/usr/local/bin/vagrant-spk", line 831, in main
    operation(args)
  File "/usr/local/bin/vagrant-spk", line 740, in vm_subcommand
    call_vagrant_command(sandstorm_dir, *args.command_specific_args)
  File "/usr/local/bin/vagrant-spk", line 234, in call_vagrant_command
    return subprocess.check_call(command, cwd=sandstorm_dir)
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['vagrant', 'up']' returned non-zero exit status 1

I tried to use $ VBoxManage modifyvm roundup_sandstorm_1462898296 --longmode off, but every vm up recreates machine, so each time the name is different. Is there a way to pass the flag there?

paulproteus commented 8 years ago

Hi there! Thanks for filing this issue.

There are two main avenues to consider.

  1. Embed this 'vboxmanage' command into your app's Vagrantfile

To do that, search for "VBOXMANAGE CUSTOMIZATIONS" at https://www.vagrantup.com/docs/virtualbox/configuration.html

That is the best answer to your question, in my opinion.

  1. Switch to using libvirt for virtualization, which I believe will fall back to non-VT-x-accelerated emulation

To do that, check out this README: https://github.com/sandstorm-io/vagrant-spk/blob/master/HOWTO-libvirt.md

This is an alternative that skips using VirtualBox entirely and uses kvm/qemu instead.

techtonik commented 8 years ago

Hi @paulproteus. Thanks for the pointers. I will try them right away.

I started process about using LXC/LXD as a superior replacement for VirtualBox and friends (in terms of performance) on Linux systems, but I run out of funds to complete the implementation stage. So if you have spare resources, it would be nice to try this alternative.

techtonik commented 8 years ago

1. Setting --longmode off didn't help, and I don't remember why it should,

techtonik commented 8 years ago

2. Switching to libvirt also failed

$ vagrant plugin install mutate
Installing the 'mutate' plugin. This can take a few minutes...
/usr/lib/ruby/2.3.0/rubygems/specification.rb:946:in `all=': undefined method `group_by' for nil:NilClass (NoMethodError)
    from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:275:in `with_isolated_gem'
    from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:231:in `internal_install'
    from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:102:in `install'
    from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:62:in `block in install_plugin'
    from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:72:in `install_plugin'
    from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:37:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `block in run'
    from /usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy'
    from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `run'
    from /usr/share/vagrant/plugins/commands/plugin/command/base.rb:14:in `action'
    from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:32:in `block in execute'
    from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `each'
    from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `execute'
    from /usr/share/vagrant/plugins/commands/plugin/command/root.rb:56:in `execute'
    from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:42:in `execute'
    from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:268:in `cli'
    from /usr/bin/vagrant:173:in `<main>'
paulproteus commented 8 years ago

This seems to be a bug in the Debian package for Vagrant: https://github.com/vagrant-libvirt/vagrant-libvirt/issues/575 and there seems to be a workaround listed there. Can you try that and let me know?

BTW I'll probably run into that shortly, so I'm glad you're trailblazing here.

paulproteus commented 8 years ago

Oh it looks like it's fixed in sid if you can update to version 1.8.1+dfsg-2.

techtonik commented 8 years ago

I am on Ubuntu 16.04 LTS and I forgot how to use package from Debian sid, so I just applied patch from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818237#28 manually. Installed mutate plugin successfully, getting back to shaving yaks.

techtonik commented 8 years ago

It looks like this step - https://github.com/sandstorm-io/vagrant-spk/blob/master/HOWTO-libvirt.md#produce-an-appropriate-box-for-usage-with-libvirt - is unnecessary.

techtonik commented 8 years ago
$ vagrant-spk vm up
Calling 'vagrant' 'up' in /home/techtonik/p/roundup/.sandstorm
The provider 'libvirt' could not be found, but was requested to
back the machine 'default'. Please use a provider that exists.

So how to install libvirt provider for Vagrant?

techtonik commented 8 years ago

Okay. Managed to install vagrant-libvirt (kind of). Now getting this:

Bringing machine 'default' up with 'libvirt' provider...
Error while connecting to libvirt: Error making a connection to libvirt URI qemu:///system?no_verify=1&keyfile=/home/techtonik/.ssh/id_rsa:
Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied
zarvox commented 8 years ago

Check the permissions/groups on that socket file:

ls -l /var/run/libvirt/libvirt-sock

If it's restricted to a particular user/group (possibly libvirt? I'm not sure how Ubuntu configures things), you might need to add yourself to the group:

sudo gpasswd -a $USER libvirt # where "libvirt" here is whichever group owns the socket

And then log out and log in again, so that your user session is marked as having that group's access. You can check by running:

groups

and you should see the group you added yourself to listed.

techtonik commented 8 years ago
$ ls -l /var/run/libvirt/libvirt-sock
srwxrwx--- 1 root libvirtd 0 May 11 20:57 /var/run/libvirt/libvirt-sock
$ groups
techtonik adm cdrom sudo dip plugdev lpadmin sambashare lxd libvirtd
techtonik commented 8 years ago

Restarted and now it fails with

Bringing machine 'default' up with 'libvirt' provider...
==> default: Uploading base box image as volume into libvirt storage...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
...
Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: invalid argument: could not find capabilities for domaintype=kvm 
techtonik commented 8 years ago

Looks like it also requires VT-x, which is absent here

$ sudo kvm-ok
INFO: Your CPU does not support KVM extensions
KVM acceleration can NOT be used
paulproteus commented 8 years ago

Per https://libvirt.org/drvqemu.html if you 'sudo dpkg -r kvm' but keep the /usr/bin/qemu binary around, it should fall back properly.

techtonik commented 8 years ago

Why do I want to remove kvm package?

paulproteus commented 8 years ago

"kvm" only works when VT-x is available, if I understand correctly, and libvirt's "qemu" driver attempts to use kvm if the kvm binary is available, so if you remove it​, you'll allow libvirt's "qemu" driver to fall back to actual qemu.

techtonik commented 8 years ago

I'd prefer a way to switch to "qemu" driver explicitly, so I used libvirt.driver = "qemu" and done apt install qemu to get a little further. It still fails with:

==> default: /opt/app/.sandstorm/global-setup.sh: line 14: /host-dot-sandstorm/caches/install.sh: Permission denied
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
techtonik commented 8 years ago

Second run seems to go ok, but I don't see anything running at http://local.sandstorm.io:6080/

$ vagrant-spk vm up
Calling 'vagrant' 'up' in /home/techtonik/p/roundup/.sandstorm
Bringing machine 'default' up with 'libvirt' provider...
techtonik commented 8 years ago

There is something running, but it says the The connection was reset.

techtonik commented 8 years ago

Looks like install.sh script failed, but it started.