Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to create a VM in bridged network mode #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sebastianrakel
Copy link
Contributor

After problems with nftables and libvirtd, i talked with @bastelfreak and we talked about managing the network with systemd-networkd and bridge VMs directly to the systemd-networkd managed bridge.

It was not possible with the current state of this module, so i added an optional setting to create a bridged interface

README.md Outdated Show resolved Hide resolved
@trefzer
Copy link
Contributor

trefzer commented Sep 25, 2024

Thanks for the request, will review soon (hopefully).
Could you tell me a little more about "problems with nftables and libvirtd" ?

@sebastianrakel
Copy link
Contributor Author

Thanks for the request, will review soon (hopefully). Could you tell me a little more about "problems with nftables and libvirtd" ?

in our case we need to ensure to first start libvirtd and then nftables only than the firewall rules are present.

if nftables is restarted the firewallrules will be dropped and the vm network is down

it's only happening if libvirtd manages the network

with this PR i can manage the network on my own and the rules are working now

@rayderua
Copy link

I have another case for bridged ndework mode.
Example from my home test environment
I have server that already have bridge

auto br0
iface br0 inet static
        bridge_ports enp3s0
        address 172.31.255.200/24
        gateway 172.31.255.1

And i want that start my domins (VMs) will be attachet to exist bridge, and works on host network
But to not manage this interface by libvirt daemon
So we need bridged configuration like this

<interface type='bridge'>
  <mac address='52:54:00:02:d5:9f'/>
  <source bridge='br0'/>
  <model type='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

README.md Outdated Show resolved Hide resolved
Co-authored-by: Kenyon Ralph <[email protected]>
@@ -1,7 +1,11 @@
<%- | Libvirt::Domain::Interface $iface,
String $boot,
| -%>
<%- if $iface['bridge_network'] and $iface['bridge_network'] == true { -%>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if $iface['bridge_network'] is enough.

@@ -22,7 +26,11 @@
</filterref>
<%- } -%>
<%- } -%>
<%- if $iface['bridge_network'] and $iface['bridge_network'] == true { -%>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if $iface['bridge_network'] is enough.

trefzer added a commit that referenced this pull request Feb 12, 2025
This is based on the idea of @sebastianrakel and @bastelfreak
in pull request #81. Besides adding bridges this also adds additional
network types.

This deprecates the 'network' and 'portgroup' parameters in favor
of the more flexible 'source' parameter in the network interface hash.
The deprecated parameters will remain functional until next major release.
@trefzer
Copy link
Contributor

trefzer commented Feb 12, 2025

@sebastianrakel, @rayderua, @kenyon
I just added pull request #84 to solve this a little bit more generic and add other network types.
Could you have a look at #84 and tell me if this would be a solution ?

Just an additional hint, the bridge configuration is already possible without this merge request, just use one of $devices or $additionaldevices parameter with the following setting:

additionaldevices => { 'interface' => [{
   - 'attrs' => { 'type' => 'bridge' }
     'values' => {
        'model' => {  'attrs' => { 'type' => 'virtio' } },
        'source' => { 'attrs' => { 'bridge' => 'virbr0' }}
     }
}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants