Where are network config files supposed to be saved for libvirt?

0

I'm having a heck of a time with libvirt. I deleted the default NAT network, and I'm trying to add a Bridge for VMs. According to libvirt's wiki and Network XML format | Using an existing host bridge, I have the following:

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

I saved the file as host-bridge.xml. I copied it to both /etc/libvirt/ and /usr/share/libvirt/schemas. However, regardless of what I try, I always get a:

$ sudo virsh net-create host-bridge
error: Failed to open file 'host-bridge': No such file or directory
$ sudo virsh net-create host-bridge.xml
error: Failed to open file 'host-bridge.xml': No such file or directory

The machine is running Ubuntu Server 14.03 LTS. According to brctl, the bridge br0 does exist, and its using eth1.

Where are network config files supposed to be saved for libvirt?

jww

Posted 2016-01-30T04:52:10.640

Reputation: 1

Answers

1

On my (CentOS) based systems they are in /var/lib/libvirt/network (and this is the same for the libvirt.org wiki answer) but the Ubuntu Wiki suggests /etc/libvirt/qemu (in the libvirt guest Configuration section)

davidgo

Posted 2016-01-30T04:52:10.640

Reputation: 49 152

0

To add to @davidgo's answer... I performed:

sudo mv /opt/libvirt/host-bridge.xml /etc/libvirt/qemu/networks

Once the network file is located where you want it:

$ sudo cat /etc/libvirt/qemu/networks/host-bridge.xml 
<network>
  <name>host-bridge</name>
  <uuid>88c0529e-4813-43fa-af27-01af164249ed</uuid>
  <forward mode='bridge'/>
  <bridge name='br0'/>
</network>

You still need to either (1) define it or (2) create it to actually use it in a VM. If you want it to be persistent, then you need to define it because that's permanent (create is transient):

virsh net-define /etc/libvirt/qemu/networks/host-bridge.xml

Once the network is defined, the UUID will be added and then you can refer to it in a VM's XML file:

sudo grep -R "host-bridge" /etc/libvirt/
/etc/libvirt/qemu/Debian_7_x86.xml:      <source network='host-bridge'/>
/etc/libvirt/qemu/Debian_7_x64.xml:      <source network='host-bridge'/>
/etc/libvirt/qemu/Debian_8_x86.xml:      <source network='host-bridge'/>
/etc/libvirt/qemu/Debian_8_x32.xml:      <source network='host-bridge'/>
/etc/libvirt/qemu/Debian_8_x64.xml:      <source network='host-bridge'/>
...

It will also show up in the networks/autostart folder:

sudo grep -R "host-bridge" /etc/libvirt/
...
/etc/libvirt/qemu/networks/autostart/host-bridge.xml:  <name>host-bridge</name>

Finally, you should see similar to the following:

$ virsh net-list --all
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 host-bridge          inactive   yes           yes

Also see libvirt's net-define (permanent), net-create (transient) and net-autostart.

jww

Posted 2016-01-30T04:52:10.640

Reputation: 1