Search code examples
qemulibvirtdnsmasq

virsh net-define does not apply dnsmasq options


I have defined network and wanted to make wildcard definition for one of VMs. No matter if I edit or re-define network, section for dnsmasq is always being ignored and not applied. So below is my network.xml file:

<network>
  <name>network</name>
  <uuid>...</uuid>
  <forward dev='enp0s25' mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
    <interface dev='enp0s25'/>
  </forward>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='...'/>
  <domain name='network'/>
  <ip address='...' netmask='...'>
    <dhcp>
      <range start='...128' end='...254'/>
      <host mac='...' name='px2-test-oc' ip='...'/>
    </dhcp>
  </ip>
  <dnsmasq:options>
    <dnsmasq:option value='cname=*.px2-test-oc.network,px2-test-oc.network'/>
    <dnsmasq:option value='auth-zone=network'/>
    <dnsmasq:option value='auth-server=network,*'/>
  </dnsmasq:options>
</network>

I apply changes by virsh net-destroy network virsh net-define network.xml

No errors reported, so when I do virsh net-dumpxml network I'm getting in response:

<network>
  <name>network</name>
  <uuid>...</uuid>
  <forward dev='enp0s25' mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
    <interface dev='enp0s25'/>
  </forward>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='...'/>
  <domain name='network'/>
  <ip address='...' netmask='...'>
    <dhcp>
      <range start='...128' end='...254'/>
      <host mac='...' name='px2-test-oc' ip='...'/>
    </dhcp>
  </ip>
</network>

I can't find what I'm doing wrong. Why it does not take changes? I also tried virsh net-edit and to delete completely by virsh net-undefine and then define but no effect. Simply this part is being ignored. Apart of that this network is and was working completely fine.

Looking for issues I started playing with logging settings for libvirtd and with

log_filters="1:qemu 1:libvirt 4:object 4:json 1:event 1:util"
log_outputs="1:file:/var/log/libvirt/libvirtd.log"

I can see that full xml definition (WITH dnsmasq options) is being passed to libvirtd but I don't see anything pointing me to why it is not applied. System is Mint/Ubuntu and libvirt is 6.0.0-0ubuntu .


Solution

  • You need to include a reference to the schema in the XML, otherwise the parser will reject the dnsmasq:options part. I.e.

    <network xmlns:dnsmasq='http://libvirt.org/schemas/network/dnsmasq/1.0'>