Bug 1706289 - vagrant up show "undefined method `+' for nil:NilClass (NoMethodError)" when using libvirt parameters
Summary: vagrant up show "undefined method `+' for nil:NilClass (NoMethodError)" when ...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: vagrant-libvirt
Version: 31
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Vít Ondruch
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-05-04 05:01 UTC by Robert de Bock
Modified: 2020-11-24 18:55 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-24 18:55:33 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Robert de Bock 2019-05-04 05:01:42 UTC
Description of problem:
After updating from Fedora 29 to Fedora 30, I see this message after `vagrant up`:

```
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain.rb:156:in `block in call': undefined method `+' for nil:NilClass (NoMethodError)
```

Version-Release number of selected component (if applicable):

```
vagrant-libvirt-0.0.45-1.fc30.noarch
vagrant-2.2.3-1.fc30.noarch

```

How reproducible:


Steps to Reproduce:
1. dnf install vagrant vagrant-libvirt
2. # go into a directory with a Vagrantfile
3. vagrant up

Actual results:

```
Traceback (most recent call last):
	35: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
	34: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/machine.rb:194:in `action'
	33: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/machine.rb:194:in `call'
	32: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/environment.rb:614:in `lock'
	31: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/machine.rb:208:in `block in action'
	30: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/machine.rb:239:in `action_raw'
	29: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/runner.rb:66:in `run'
	28: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/util/busy.rb:19:in `busy'
	27: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/runner.rb:66:in `block in run'
	26: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/builder.rb:116:in `call'
	25: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	24: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	23: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	22: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/builtin/box_check_outdated.rb:84:in `call'
	21: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	20: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/builtin/call.rb:53:in `call'
	19: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/runner.rb:66:in `run'
	18: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/util/busy.rb:19:in `busy'
	17: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/runner.rb:66:in `block in run'
	16: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/builder.rb:116:in `call'
	15: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	14: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
	13: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	12: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/set_name_of_domain.rb:35:in `call'
	11: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	10: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
	 9: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	 8: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
	 7: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	 6: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/handle_box_image.rb:146:in `call'
	 5: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	 4: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain_volume.rb:83:in `call'
	 3: from /usr/share/vagrant/gems/gems/vagrant-2.2.3/lib/vagrant/action/warden.rb:34:in `call'
	 2: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain.rb:147:in `call'
	 1: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain.rb:147:in `each'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain.rb:156:in `block in call': undefined method `+' for nil:NilClass (NoMethodError)
```

Expected results:

A running vm.

Additional info:
This happens only when specifying libvirt parameters like these:
```
  config.vm.define "fedora29" do |config|
    config.vm.box = "fedora/29-cloud-base"
    config.vm.provider :libvirt do |libvirt|
      libvirt.storage :file, :size => '20G'
    end
  end
```

Comment 1 Vít Ondruch 2019-05-06 10:05:01 UTC
I can confirm the issues. It seems it is related to:

https://fedoraproject.org/wiki/Changes/Vagrant_2.2_with_QEMU_Session#Upgrade.2Fcompatibility_impact

IOW using system instead of user session is workaround:

~~~
  config.vm.provider :libvirt do |libvirt|
    libvirt.qemu_use_session = false
  end
~~~

However, I wonder what is so specific about Fedora cloud images network settings, which would trigger this issue? Any idea?

Comment 2 Pavel Valena 2019-08-21 14:48:34 UTC
In general to this upgrade, which is what probably happened, anything associated with your previous VM instances(and the instances themselves) can't be accesible with the upgraded Vagrant version  unless you change the current default setting, as Vit mentined.

That is because it newly uses unprivilleged libvirt access `qemu:///session`, instead of the default, privilleged, `qemu:///system`.

Therefore anything that was created before the upgrade is still in the `qemu:///system` domain and unaccessible via `qemu:///session`. Newly created, or re-created, images should be fine.

The following could possibly also help:
  - destroy the instance before upgrade and create new with new version
  - change fedora29 in `config.vm.define "fedora29"` to some other string, to be non-conflicting
  - use `virsh` to list/modify/remove the libvirt `objects` manually (`sudo virsh` and `virsh` also have different access)

Unfortunatelly I know of no way we can safely port all images to `qemu:///session` for this upgrade to be transparent to users. Therefore user needs to re-create the images or the switch off qemu_use_session value. The upgrade is not expected to be seamless, but I agree the traceback message is awful. Maybe that could be fixed?

Comment 3 Dusty Mabe 2019-11-16 03:30:24 UTC
Something like this happens to me on latest F31. I've noticed that it only happens when I have a second disk `domain.storage :file, :size => '20G'` in my Vagrantfile:

```
vagrant-2.2.5-1.fc31.noarch
vagrant-libvirt-0.0.45-3.fc31.noarch
```

```
         2: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain.rb:147:in `call'                                                                                                        
         1: from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain.rb:147:in `each'                                                                                                        
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.45/lib/vagrant-libvirt/action/create_domain.rb:156:in `block in call': undefined method `+' for nil:NilClass (NoMethodError)
```

```
Vagrant.configure(2) do |config|

    config.ssh.insert_key = 'true'
#   config.ssh.forward_agent = 'true'
#

    config.vm.synced_folder "/var/b/shared", "/var/b/shared", type: "sshfs"

    config.vm.provider :libvirt do |domain|
      domain.memory = 4096
      domain.cpus = 4
      domain.nested = true
      # Add an extra disk
      domain.storage :file, :size => '20G'
     #domain.volume_cache = 'none'
    end

    host = 'vanilla-f31'
    box  = 'fedora/31-cloud-base'

    config.vm.define host do | tmp |
        tmp.vm.hostname = host
        tmp.vm.box = box
    end
end
```

Comment 4 Dusty Mabe 2019-12-05 14:41:39 UTC
Just from browsing the title of the PR this may be fixed by upstream PR: https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1030

Comment 5 Raghavendra Talur 2019-12-09 23:20:01 UTC
I hit this issue too. Also, I think, along with the patch mentioned in comment 4, it would require fog-libvirt version 6 and above because of the following two changes
https://github.com/fog/fog-libvirt/releases

Allow to specify UID and GID of volume
Scope code under Fog::Libvirt instead of Fog::Compute::Libvirt

Comment 6 Ben Cotton 2020-11-03 16:47:04 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 7 Ben Cotton 2020-11-24 18:55:33 UTC
Fedora 31 changed to end-of-life (EOL) status on 2020-11-24. Fedora 31 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.