Vagrant-libvirt: More descriptive "could not find capabilities"

Created on 12 May 2016  路  5Comments  路  Source: vagrant-libvirt/vagrant-libvirt

Steps to reproduce

  1. #539

    Expected behaviour

Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: invalid argument: could not find capabilities for domaintype=qemu: can't find "qemu" binary

Actual behaviour

Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: invalid argument: could not find capabilities for domaintype=kvm 
Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: invalid argument: could not find capabilities for domaintype=qemu

System configuration

OS/Distro version:: Ubuntu 16.04 LTS

Libvirt version: ??? how to get it?

Output of vagrant version; vagrant plugin list:
Installed Version: 1.8.1

Vagrant was unable to check for the latest version of Vagrant.
Please check manually at http://www.vagrantup.com
mutate (1.0.0)
vagrant-libvirt (0.0.33)

Output of VAGRANT_LOG=debug vagrant ... --provider=libvirt

...
INFO interface: info:  -- Command line : 
 INFO interface: info: ==> default:  -- Command line : 
==> default:  -- Command line : 
ERROR warden: Error occurred: Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: invalid argument: could not find capabilities for domaintype=qemu 
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
...
ERROR vagrant: /home/techtonik/.vagrant.d/gems/gems/vagrant-libvirt-0.0.33/lib/vagrant-libvirt/action/create_domain.rb:230:in `rescue in call'
/home/techtonik/.vagrant.d/gems/gems/vagrant-libvirt-0.0.33/lib/vagrant-libvirt/action/create_domain.rb:226:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/home/techtonik/.vagrant.d/gems/gems/vagrant-libvirt-0.0.33/lib/vagrant-libvirt/action/create_domain_volume.rb:51:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/home/techtonik/.vagrant.d/gems/gems/vagrant-libvirt-0.0.33/lib/vagrant-libvirt/action/handle_box_image.rb:111:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/builtin/handle_box.rb:56:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/home/techtonik/.vagrant.d/gems/gems/vagrant-libvirt-0.0.33/lib/vagrant-libvirt/action/handle_storage_pool.rb:50:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/home/techtonik/.vagrant.d/gems/gems/vagrant-libvirt-0.0.33/lib/vagrant-libvirt/action/set_name_of_domain.rb:35:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:95:in `block in finalize_action'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `block in run'
/usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy'
/usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `run'
/usr/lib/ruby/vendor_ruby/vagrant/action/builtin/call.rb:53:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/builtin/config_validate.rb:25:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `block in run'
/usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy'
/usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `run'
/usr/lib/ruby/vendor_ruby/vagrant/machine.rb:224:in `action_raw'
/usr/lib/ruby/vendor_ruby/vagrant/machine.rb:199:in `block in action'
/usr/lib/ruby/vendor_ruby/vagrant/environment.rb:527:in `lock'
/usr/lib/ruby/vendor_ruby/vagrant/machine.rb:185:in `call'
/usr/lib/ruby/vendor_ruby/vagrant/machine.rb:185:in `action'
/usr/lib/ruby/vendor_ruby/vagrant/batch_action.rb:82:in `block (2 levels) in run'
 INFO interface: error: Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: invalid argument: could not find capabilities for domaintype=qemu 
Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: invalid argument: could not find capabilities for domaintype=qemu 
...

A Vagrantfile to reproduce the issue:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Guess at a reasonable name for the VM based on the folder vagrant-spk is
# run from.  The timestamp is there to avoid conflicts if you have multiple
# folders with the same name.
VM_NAME = File.basename(File.dirname(File.dirname(__FILE__))) + "_sandstorm_#{Time.now.utc.to_i}"

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # Base on the Sandstorm snapshots of the official Debian 8 (jessie) box.
  config.vm.box = "sandstorm/debian-jessie64"

  if Vagrant.has_plugin?("vagrant-vbguest") then
    # vagrant-vbguest is a Vagrant plugin that upgrades
    # the version of VirtualBox Guest Additions within each
    # guest. If you have the vagrant-vbguest plugin, then it
    # needs to know how to compile kernel modules, etc., and so
    # we give it this hint about operating system type.
    config.vm.guest = "debian"
  end

  # We forward port 6080, the Sandstorm web port, so that developers can
  # visit their sandstorm app from their browser as local.sandstorm.io:6080
  # (aka 127.0.0.1:6080).
  config.vm.network :forwarded_port, guest: 6080, host: 6080

  # Use a shell script to "provision" the box. This installs Sandstorm using
  # the bundled installer.
  config.vm.provision "shell", inline: "sudo bash /opt/app/.sandstorm/global-setup.sh", keep_color: true
  # Then, do stack-specific and app-specific setup.
  config.vm.provision "shell", inline: "sudo bash /opt/app/.sandstorm/setup.sh", keep_color: true

  # Shared folders are configured per-provider since vboxsf can't handle >4096 open files,
  # NFS requires privilege escalation every time you bring a VM up,
  # and 9p is only available on libvirt.

  # Calculate the number of CPUs and the amount of RAM the system has,
  # in a platform-dependent way; further logic below.
  cpus = nil
  total_kB_ram = nil

  host = RbConfig::CONFIG['host_os']
  if host =~ /darwin/
    cpus = `sysctl -n hw.ncpu`.to_i
    total_kB_ram =  `sysctl -n hw.memsize`.to_i / 1024
  elsif host =~ /linux/
    cpus = `nproc`.to_i
    total_kB_ram = `grep MemTotal /proc/meminfo | awk '{print $2}'`.to_i
  elsif host =~ /mingw/
    # powershell may not be available on Windows XP and Vista, so wrap this in a rescue block
    begin
      cpus = `powershell -Command "(Get-WmiObject Win32_Processor -Property NumberOfLogicalProcessors | Select-Object -Property NumberOfLogicalProcessors | Measure-Object NumberOfLogicalProcessors -Sum).Sum"`.to_i
      total_kB_ram = `powershell -Command "Get-CimInstance -class cim_physicalmemory | % $_.Capacity}"`.to_i / 1024
    rescue
    end
  end
  # Use the same number of CPUs within Vagrant as the system, with 1
  # as a default.
  #
  # Use at least 512MB of RAM, and if the system has more than 2GB of
  # RAM, use 1/4 of the system RAM. This seems a reasonable compromise
  # between having the Vagrant guest operating system not run out of
  # RAM entirely (which it basically would if we went much lower than
  # 512MB) and also allowing it to use up a healthily large amount of
  # RAM so it can run faster on systems that can afford it.
  if cpus.nil? or cpus.zero?
    cpus = 1
  end
  if total_kB_ram.nil? or total_kB_ram < 2048000
    assign_ram_mb = 512
  else
    assign_ram_mb = (total_kB_ram / 1024 / 4)
  end
  # Actually apply these CPU/memory values to the providers.
  config.vm.provider :virtualbox do |vb, override|
    vb.cpus = cpus
    vb.memory = assign_ram_mb
    vb.name = VM_NAME
    vb.customize ["modifyvm", :id, "--nictype1", "Am79C973", "--longmode", "off"]

    override.vm.synced_folder "..", "/opt/app"
    override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm"
    override.vm.synced_folder "..", "/vagrant", disabled: true
  end
  config.vm.provider :libvirt do |libvirt, override|
    libvirt.cpus = cpus
    libvirt.driver = "qemu"
    libvirt.memory = assign_ram_mb
    libvirt.default_prefix = VM_NAME

    override.vm.synced_folder "..", "/opt/app", type: "9p", accessmode: "passthrough"
    override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm", type: "9p", accessmode: "passthrough"
    override.vm.synced_folder "..", "/vagrant", type: "9p", accessmode: "passthrough", disabled: true
  end
end

Are you using upstream vagrant package or your distros package?
Distro

Most helpful comment

The invalid argument: could not find capabilities for domaintype=kvm is seen if the CPU does not support virtualization and/or the kvm kernel module is not loaded.

Here are the commands that can be used to check if the CPU supports virtualization and if the kvm kernel module is loaded:

# grep -i vmx /proc/cpuinfo
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt

#  lsmod | grep kvm
kvm_intel             170181  0 
kvm                   554609  1 kvm_intel
irqbypass              13503  1 kvm

All 5 comments

This is not a vagrant error, this is libvirt itself reporting the issue and in a very generic way, so we can't really do anything about it in the first place. It is assumed that the user ensures libvirt is installed correctly as mentioned in the documentation.

The only thing we may be able to do is to parse virsh capabilities and then check whether if the defined VM can actually be started before we submit to libvirt, but the effect is the same - it is still up to the user to ensure libvirt works correctly.

So I think the best option is to document the error and let the user handle it. I've added this to the wiki for now.

Installation docs doesn't mention that qemu needs to be installed.

@techtonik i consider it implied that if you install libvirt, which is a library to manage virtualization, that you also install a virtualization technology. It is out of scope for vagrant-libvirt but I will update the documentation to clarify this.

The invalid argument: could not find capabilities for domaintype=kvm is seen if the CPU does not support virtualization and/or the kvm kernel module is not loaded.

Here are the commands that can be used to check if the CPU supports virtualization and if the kvm kernel module is loaded:

# grep -i vmx /proc/cpuinfo
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt

#  lsmod | grep kvm
kvm_intel             170181  0 
kvm                   554609  1 kvm_intel
irqbypass              13503  1 kvm
Was this page helpful?
0 / 5 - 0 ratings