AshleyYakeley / NixVirt

LibVirt domain management for Nix
MIT License
191 stars 21 forks source link

Forward bridge networks not supported #62

Open szethh opened 1 month ago

szethh commented 1 month ago

Hi. I was trying to set up a simple bridge network (see below), but I ran into the following error:

[ERROR]   stderr) okt 01 22:29:54 flat nixvirt-start[12725]: NixVirt: libvirt error: unsupported configuration: Unsupported <mac> element in network bridged-network with forward mode='bridge'

Now this is weird because my definition does not contain any <mac> element:

<network>
  <name>bridged-network</name>
  <uuid>cc7439ed-36af-4696-a6f2-1d0c4474d87e</uuid>
  <forward mode="bridge" />
  <bridge name="br0" />
</network>

The nix side of things just imports the file as-is:

networks = [
  {
    definition = ./network.xml;
    active = true;
  }
];

I think it might be because of this snippet? It seems to expect a <mac> entry to exist in every network, and adds it if not found. This should probably not apply for bridge networks.

https://github.com/AshleyYakeley/NixVirt/blob/1d5c17c1f3a03f5d7e4dacc1025db350190f8f6c/tool/nixvirt.py#L175-L185

AshleyYakeley commented 1 month ago

This is surprising. As you can see from the snippet, the code already checks the "mode" attribute and should not futz around with the MAC address if it's set to "bridge".