Can't start VM from virt-manager: network 'default' is not active

I have set up a VM using virt-manager (QEMU/KVM). It was starting up fine the first time I ran it.

Then I rebooted and now I can’t start it again:

Error starting domain: Requested operation is not valid: network 'default' is not active

Traceback (most recent call last):
  File "/nix/store/hrw1bxzzvfmrz6hycnb2vgacnha57ijk-virt-manager-4.1.0/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/nix/store/hrw1bxzzvfmrz6hycnb2vgacnha57ijk-virt-manager-4.1.0/share/virt-manager/virtManager/asyncjob.py", line 108, in tmpcb
    callback(*args, **kwargs)
  File "/nix/store/hrw1bxzzvfmrz6hycnb2vgacnha57ijk-virt-manager-4.1.0/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
    ret = fn(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/hrw1bxzzvfmrz6hycnb2vgacnha57ijk-virt-manager-4.1.0/share/virt-manager/virtManager/object/domain.py", line 1402, in startup
    self._backend.create()
  File "/nix/store/0fvgbg1nd4w6yd1983vipzfkf8q7zbpy-python3.11-libvirt-9.9.0/lib/python3.11/site-packages/libvirt.py", line 1373, in create
    raise libvirtError('virDomainCreate() failed')
libvirt.libvirtError: Requested operation is not valid: network 'default' is not active

I tried these commands:

$ virsh net-list --all
 Name   State   Autostart   Persistent
----------------------------------------

$ virsh net-start default
error: failed to get network 'default'
error: Network not found: no network with matching name 'default'

I can’t figure out what is the problem here…

2 Likes

Does this help?

1 Like

For me, it was as simple as running all this virsh commands with sudo :smile:

If you really don’t have a default network set up, you may also look at libvirt network hook, that can be included by virtualisation.libvirtd.hooks.network option.

You can then apply the @ahen’s fix to get the things rolling.

Just had the same problem and this helped, weirdly it didn’t work as root but as my user:

k@nixos /tmp> sudo virsh net-define --file default.xml
[sudo] password for k: 
error: Failed to define network from default.xml
error: operation failed: network 'default' already exists with uuid 057ce490-0e65-4e33-9e69-a7ee8bc00575

k@nixos /tmp [1]> virsh net-define --file default.xml
Network default defined from default.xml

so this command would need to be ran as hook?

Running it as root is not a good solution, I mean there is

 virtualisation.qemu.runAsRoot = false;

I was confused by this also.

The solution is to go to:
“Edit” →
“Connection Details” →
“Virtual Networks” →
Click the little “Play” button

Not sure how to auto magically do this via nix though…

2 Likes