In a discussion spawned from the issue to connect to libvirt through ssh we discussed about using libvirt with the usual default of qemu://session right after installing libvirt* packages as there are some hurdles to pass - those hurdles do not exist as soon as you re-login btw.
What will happen is like:
$ apt install libvirt-daemon-system
$ virsh list
error: failed to connect to the hypervisor
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock':
Permission denied
But actually slightly more sinister is when it works but you later miss your guests. Which is due to the default right after install being from the binaries which is qemu:///session (in newer versions where this was changed).
$ apt install libvirt-daemon-system $ virsh uri qemu:///session
The reason for the issues above is that two things are missing in your current shell (or script) right after install.
Messing with the users login as package install time was discussed, but discarded for having too much potential to break things for something that fortunately is a corner case. But if you want to e.g. in one script install libvirt and use it you need some minor adaptions to be able to do so.
Thanks @marosg for the discussion about this!