Libvirt compute resource with forwarded network

Hi all,

Just finished fresh installation of Foreman 1.16.

Now I want to import some VMs from my libvirt node as foreman hosts. I was able to configure compute resource and can see desired VM in the list. But when I press “Actions” -> “Import” the error appears:

Call to virNetworkGetBridgeName failed: internal error: network '<libvirt network name>' does not have a bridge name.

Which is absolutely correct. This network is a group of forwarded virtual functions from my NIC. Its xml looks like this:

<network>
  <name>vf-pool</name>
  <forward mode='hostdev' managed='yes'>
    <pf dev='eth0'/>
  </forward>
</network>

But VM is not imported.

Is this a bug or some kind of misconfiguration on my side?

Thanks!

Can you create new VMs on that network? My guess is that network mode isn’t supported, but I’m not sure of the XML for ones that are, so I’m not 100% sure. I know we can do bridges and NAT subnets, so if it’s something else it may not work.

Thank you for your reply.

I cannot create any VM on this compute resource at all. Same error in the logs:

 | Libvirt::Error: Call to virNetworkGetBridgeName failed: internal error: network 'vf-pool' does not have a bridge name.
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-libvirt-0.4.1/lib/fog/libvirt/requests/compute/list_networks.rb:33:in `bridge_name'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-libvirt-0.4.1/lib/fog/libvirt/requests/compute/list_networks.rb:33:in `network_to_attributes'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-libvirt-0.4.1/lib/fog/libvirt/requests/compute/list_networks.rb:9:in `block in list_networks'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-libvirt-0.4.1/lib/fog/libvirt/requests/compute/list_networks.rb:8:in `each'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-libvirt-0.4.1/lib/fog/libvirt/requests/compute/list_networks.rb:8:in `list_networks'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-libvirt-0.4.1/lib/fog/libvirt/models/compute/networks.rb:11:in `all'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-core-1.45.0/lib/fog/core/collection.rb:112:in `lazy_load'
 | /opt/theforeman/tfm/root/usr/share/gems/gems/fog-core-1.45.0/lib/fog/core/collection.rb:16:in `any?'
 | /usr/share/foreman/app/helpers/compute_resources_vms_helper.rb:70:in `libvirt_networks'
 | /usr/share/foreman/app/views/compute_resources_vms/form/libvirt/_network.html.erb:5:in `_4db7854ea14a32521faca081360e51d7'

This is discouraging. One unsupported network renders compute resource unusable.

I guess some kind of error handling is required - I will be quite happy without this network in Foreman, but with my normal “bridged” virtual machines.

Indeed, better errors are always good. As I say, I’m not 100% confident on my answer because it’s been a while since I looked at the libvirt code myself. Hopefully someone else from @core can offer an opinion…

In the meantime, a bug report for getting improved error handling added is very welcome - would you happy to open one on our tracker? Thanks!

This looks like a bug in fog-libvirt because what we call is simply
list_networks and it blows up down the stack. I suggest to create a simple
ruby example and report bug in fog.

LZ

1 Like

Well, looks like issue already exists:

Mmm, a year old does not look good, might be worth a comment saying you’re still hitting this.

We should definitely catch errors like that if we can though - as you say, you have other VMs which can be associated but are prevented by this issue. Do log that in our tracker if you have a moment.

By the way, I think you can associate individual VMs from the host edit page (that is, create a host for them as a bare metal host, or using a Puppet report, and then associate it to the VM), but I’ll have to go check to be sure…

Thank you for help,
I was unable to associate a VM to manually created host, it said: “No host found to associate this VM with”.
Not sure if this is connected to original problem. Nevertheless I’m going to configure facts upload now, so hosts will be automatically created, and I’ll have another go then.

Issue in tracker: Bug #22259: Libvirt hostdev network breaks entire compute resource - Foreman

Yeah you’ll need a host object to associate to. As you say, creating from facts or a puppet report should do it.

Sorry for delay.

I can confirm that host association works correctly. And I am able to access VM console.

1 Like

OK great, at least you can add the working hosts. Hopefully the fog side issues can be fixed…