Hello fellow nix users .
I have just setup virt-manager in nixos, and everytime i reboot and open virt-manger and try to run any virtual machine i get this error:
Error starting domain: Requested operation is not valid: network 'default' is not active
I managed to solve this error by running: sudo virsh net-start default however this will work until you reboot the machine you will have to run it again, following this article, it explains that you have to run sudo virsh net-autostart --network default if you want to auto start that daemon automatically on startup.
The only reason i have not applied the second solution is because i am on nixos, and i am making the assumption that there will be a nixos config that does the same thing + if there is (that would be good since it will be declared in the config).
To me sounds like according to my understanding of the article one needed to set virtualisation.libvirtd.allowedBridges to what is deemed “default” (“virbr0” in the article again).
Some links around here discussing the bridge interface workings:
The systemd service automatically starts the libvirt default network on boot:
after = ["libvirtd.service"] ensures it only runs after libvirtd is ready
wantedBy = ["multi-user.target"] makes it start automatically at boot
Type = "oneshot" with RemainAfterExit = true means it runs once and systemd considers it active
ExecStart runs virsh net-start default when the service starts
ExecStop runs virsh net-destroy default on shutdown/stop for clean teardown
This is the NixOS equivalent of running sudo virsh net-autostart default on other distributions. The network will now automatically be available whenever you start virt-manager, eliminating the “network ‘default’ is not active” error.
just out of curiosity, since we declare the extraGroups elsewhereunder users in our config, currently i am forced to give that option in users line instead of declaring the libvirtd extragroups near the libvirt vonfig line. How to do this?
I want a method where it should work well like commenting the above whole virt-manager thing will revert my extragroups back to normal instead of going to users line and removing the libvirtd.
edit:
is this the neat way? users.groups.libvirtd.members = ["alice"];
Yes. As far as I understand, that is the neat way. Thanks for pointing it out, though. I’ll update the code in my post.(Edit: Ah… I can’t edit the post anymore)
Also, you can make the other approach (users.users.<myuser>.extraGroups = [ "libvirtd" ];) work by using nix modules. Tutorial here.
Hey, this almost worked. But I got a minor bug here, where I open virt-manager it stays on "Connecting to KVM/QEMU " something. And only when I close and reopen the app it works fine showing my guest OSs.
I’m okay with this now, but would love to have a solution
Which channel are you using? I’m on nixpkgs-unstable and it looks like the connection setting is already included as part of the virt-manager, so I don’t need to redefine it in my config.
Here’s my full virt-manager module, if you’re curious: