Apply libvirt nwfilter without editing of XML

kvm-virtualizationlibvirtnetworkingvirtualization

Is it possible to apply libvirt's network filter to a KVM guest without manually editing the XML (for use in scripts)?
Or is there any easy way of pushing the network filter configuration into existing XML? For example I have guest's configuration:

<interface type='bridge'>
    <mac address='52:54:00:d6:b6:a9'/>
    <source bridge='bridge0'/>
    <model type='virtio'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

and I need to make it:

<interface type='bridge'>
    <mac address='52:54:00:d6:b6:a9'/>
    <source bridge='bridge0'/>
    <model type='virtio'/>
    <filterref filter='clean-traffic'>
        <parameter name='IP' value='192.168.0.20'/>
    </filterref>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

Thank you!

Best Answer

Unfortunately, there is no way to apply network filters without editing the guest's definition.