18.04: VM fails to start due to management_network assuming non-existent interface eth0

Bug #1784229 reported by TJ
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
vagrant-libvirt
New
Unknown
vagrant-libvirt (Ubuntu)
New
Undecided
Unassigned

Bug Description

In trying to launch a standard ubuntu/bionic64 Vagrant box on 18.04 LTS I found it fails with the report:

Call to virDomainCreateWithFlags failed: Unable to get index for interface eth0: No such device"

which is directly from libvirt (same error in syslog).

For many hours I thought it was due to my not getting a config.vm.network :public_network, ... statement correct in Vagrantfile. Finally I commented it out and the error still occurred!

At that point I realised the culprit is the 'hidden' management_network configuration. I dived into the source-code and see that there is no attribute exposed to set the @device value and therefore it uses the default of "eth0":

lib/vagrant-libvirt/action/create_network_interfaces.rb:85: @device = iface_configuration.fetch(:dev, 'eth0')

This is becoming even more of an issue now that most distributions are using systemd/udevd > v197 "Predictable Network Interface Names" ( https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ ).

It is definitely something to be solved in this module rather than requiring what could be disruptive changes to the host configuration via kernel command-line net.ifnames=0 biosdevname=0.

This needs documenting as a gotcha up-front for newcomers especially (in docs and in the generated Vagrantfile) and an attribute provided to over-ride the interface device name at a minimum.

It would be preferable to detect the host's interface. Manually that is achieved with:

brctl show $(virsh net-info vagrant-libvirt | awk '/^Bridge:/{print $2}' ) | awk 'NR != 1{print $4}'

I did try working around it using an alias, but that isn't exposed in any useful way as an alternate name, as in:

sudo ip link set virbr1-nic alias eth0

Upstream have added an attribute to control @device since:

commit 7f50ca2
Author: qazokm <email address hidden>
Date: Fri Feb 23 12:09:49 2018 +0800

Add basic networking support for qemu session

which has added this among many other additions:

@management_network_device = 'virbr0' if @management_network_device == UNSET_VALUE
@system_uri = 'qemu:///system' if @system_uri == UNSET_VALUE

Tags: bionic
Changed in vagrant-libvirt:
status: Unknown → New
Revision history for this message
TJ (tj) wrote :

I'm currently working around it by bind-mounting the upstream source over the Ubuntu package thus:

mkdir -p /home/all/SourceCode/vagrant
cd /home/all/Sourcecode/vagrant
git clone https://github.com/vagrant-libvirt/vagrant-libvirt.git
sudo mount --bind /home/all/SourceCode/vagrant/vagrant-libvirt /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.0.43

After this I can use management_network_device in the Vagrantfile. E.g.:

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

        config.vm.define :tactyle do |tactyle|

                tactyle.vm.box = "ubuntu/bionic"

                tactyle.vm.network :public_network,
                        :dev => "virbr0",
                        :mode => "bridge",
                        :type => "bridge"

                # tactyle.vm.synced_folder "../data", "/vagrant_data"
                tactyle.ssh.insert_key = false

                tactyle.vm.hostname = "tactyle"
                tactyle.vm.provider :libvirt do |libvirt|
                        # volatile memory in MegaBytes
                        libvirt.memory = 1024
                        # virtual CPU qty
                        libvirt.cpus = 4
                        # headless system (no video output)
                        libvirt.graphics_type = "none"
                        # UK keyboard
                        libvirt.keymap = "en-gb"
                        # VM architecture requires 64-bit
                        libvirt.machine_arch = "x86_64"
                        # pass the host's /dev/random device to the guest
                        libvirt.random :model => "random"
                        # set the management interface
                        libvirt.management_network_device = 'virbr1'
                end

Alas, although the VM now starts, it fails in the initramfs and drops to the shell due to the root fs block device missing!

tags: added: bionic
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.