zweiund40
zweiund40

Reputation: 95

issue with kvm/libvirt and linux-namespaces

I have an issue with kvm/libvirt virtualization and network namespaces on my Ubuntu 16.04 LTS. What I want to do is the following fenced setup:

The intention is to get a little lab on my laptop which is fully independent from the host's remaining network setup that has communication to the outside world and it seems to me that network namespaces are the way to attain this but I hit some snags.

Until now I've set up the following:

ip netns add internalSpielwiese
ip netns exec internalSpielwiese bash
    ip addr add 127.0.0.1/8 dev lo
    ip link set lo up
    ip link add name iBr0 type bridge
    ip addr add 172.0.0.1/24 dev iBr0
    ip link set iBr0 up
    ip link add name iBr1 type bridge
    ip addr add 172.0.1.1/24 dev iBr1
    ip link set iBr1 up

Pinging the ips inside the namespace is successful. IP forwarding is enabled. Outside the namespace the bridges are not visible/existent. Now it would be time to make the bridges in libvirt known. But it doesn't work. I tried it with this xml

<network>
  <name>internalBr0</name>
  <uuid>3f4647d9-0c19-509f-b512-9cac91c7149b</uuid>
  <forward mode='bridge'/>
  <bridge name='iBr0'/>
</network>

and appropriate virsh net-define and net-start commands. I edited a VM's xml file and started the VM but the result was this:

virsh # start kirke2
error: Failed to start domain kirke2
error: Cannot get interface MTU on 'iBr0': No such device

Obviously, libvirt didn't find the iBr0 in the namespace internalSpielwiese and after some googling I've got the impression that libvirt is not able to deal with network namespaces. Or is there a way? How?

Upvotes: 0

Views: 3364

Answers (1)

DanielB
DanielB

Reputation: 2816

Libvirt can only see resources that are located in the same namespaces that libvirtd is running in. So the devices in your private namespace are invisible to libvirtd. There's no good way around this at this time, aside from making libvirtd run in this custom network namespace too. Then the host NICs are invisible to libvirtd - whether this is a problem or not depends on what you try todo.

Upvotes: 1

Related Questions