Libvirt/qemu autostart vm with bridge network

I’m setting up a network bridge so Libvirt/qemu guest VMs can be on the same subnet as my LAN. This is required for the VMs to get to some networked tuners that it can only do on the same subnet. I can do this with the follow script:

#!/bin/bash

sudo nmcli con add ifname br0 type bridge con-name br0
sudo nmcli con add type bridge-slave ifname eno1 master br0
#
sudo nmcli con modify br0 bridge.stp no
#
sudo nmcli con down "Wired connection 1"
sudo nmcli con up br0

I would like to autostart a VM so that when I reboot that VM gets started. This is normally done with:
virsh autostart ‘vm-name’

However, currently if I reboot the PC, the vm is not started. If I change the VM to use the default network “NAT”, then the VM will autostart.

I’m suspecting that there maybe a race condition between when the PC’s bridge gets setup and when virsh wants to start the VM that is marked for autostart.

Any Ideas?

What does the following command output?

virsh net-list --all

Well It used to only lists my Default network, but then I activated a bridged-network pointing to my br0 bridge that I added via nmcli. I created a file called bridge-network.xml with:

<network>
    <name>bridged-network</name>
    <forward mode="bridge" />
    <bridge name="br0" />
</network>

Then I defined that network with:
sudo virsh net-define bridge-network.xml

After I started and autostarted the new bridged-network my VM started on boot. I’m still confused because my VM uses the br0 network instead of the virtual: bridged-network, but it seems to work, at least right now.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.