Libvirt internal error: connection not open while trying to define network filter

I am trying to define a network filter using virsh console in libvirt with the following command:

runuser -u CherryWorker -- virsh nwfilter-define --file "${DIR_LIBVIRT}filters/isolated-nat-filter.xml"

This is the result I get:
error: Failed to define network filter from /opt/cherry-vm-manager/libvirt/filters/isolated-nat-filter.xml
error: internal error: connection not open


The issue is within the `connection not open` error.
I am executing virsh commands using a dedicated user that has been configured to use virsh adequately - it was added to the libvirt system group and libvirtd.socket and libvirtd-ro.socket have been modified per documentation. 
Executing the same nwfilter-define command from bare root account succeeds.

At the same time running other virsh command succeeds:

runuser -u CherryWorker – virsh net-define --file “${DIR_LIBVIRT}networks/isolated-nat.xml”

Result:

Network isolated-nat defined from /opt/cherry-vm-manager/libvirt/networks/isolated-nat.xml


Is this an issue with libvirt daemon configuration or does nwfilter-define work in some different way?

Turns out, my assumptions were faulty.
If qemu:///session is used (by default if any user other than root executes virsh command without setting the correct env variable), the only networking available is qemu usermode.
Solution:
set VIRSH_DEFAULT_CONNECTION_URI=‘qemu:///system’
in your terminal/bash script to make sure that your user (other than root) connects to the system session (of course it needs to be a member of libvirt group).

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