The issue you're encountering on Debian 13 ARM where virsh list --all returns no virtual machines, but sudo virsh list --all does, is likely related to permissions or group membership not being properly applied. Here’s how to diagnose and fix it:
Group Membership:
libvirt group grants access to manage virtual machines via virsh without sudo.libvirt group, the group permissions might not be applied to the current session.Session Refresh:
libvirt) require a new login session to take effect.libvirt group recently, you may need to log out and log back in or restart your terminal session.Polkit Rules:
virsh requires Polkit (PolicyKit) permissions to allow non-root users to interact with libvirtd.libvirt group.AppArmor/SELinux:
libvirtd for non-root users.Libvirt Socket Permissions:
libvirtd (typically /var/run/libvirt/libvirt-sock) must be accessible by the libvirt group.ls -l /var/run/libvirt/libvirt-socksrw-rw---- 1 root libvirt 0 [date] /var/run/libvirt/libvirt-socksudo chown root:libvirt /var/run/libvirt/libvirt-sock
sudo chmod 660 /var/run/libvirt/libvirt-sockRun:
groupsEnsure libvirt is listed. If not, add your user to the group:
sudo usermod -aG libvirt $USERThen log out and log back in (or restart your terminal).
Run:
ls -l /var/run/libvirt/libvirt-sockIf the group is not libvirt or permissions are not 660, fix it as shown above.
libvirtdRestart the libvirtd service to apply changes:
sudo systemctl restart libvirtdIf Polkit is used, ensure there are rules allowing the libvirt group to manage VMs.
Check for Polkit-related errors in:
journalctl -u polkit --no-pager -n 50If needed, create a Polkit rule file (e.g., /etc/polkit-1/rules.d/50-libvirt.rules) with:
polkit.addRule(function(action, subject) {
if (action.id == "org.libvirt.unix.manage" &&
subject.isInGroup("libvirt")) {
return polkit.Result.YES;
}
});Then restart Polkit:
sudo systemctl restart polkitFor AppArmor:
sudo aa-statusIf libvirtd is confined, try temporarily disabling AppArmor:
sudo systemctl stop apparmorTest if virsh list --all works. If it does, adjust the AppArmor profile for libvirtd.
For SELinux (less common on Debian):
sudo sestatusIf enabled, check for denials:
sudo ausearch -m avc -ts recentTemporarily set SELinux to permissive mode to test:
sudo setenforce 0LIBVIRT_DEFAULT_URIExplicitly set the URI for virsh to use the system connection:
export LIBVIRT_DEFAULT_URI="qemu:///system"
virsh list --allIf this works, add the export line to your ~/.bashrc or ~/.profile.
libvirtd LogsLook for errors in:
journalctl -u libvirtd --no-pager -n 50# 1. Verify group membership
groups
# 2. Fix group membership if needed
sudo usermod -aG libvirt $USER
# Log out and back in
# 3. Check socket permissions
ls -l /var/run/libvirt/libvirt-sock
sudo chown root:libvirt /var/run/libvirt/libvirt-sock
sudo chmod 660 /var/run/libvirt/libvirt-sock
# 4. Restart libvirtd
sudo systemctl restart libvirtd
# 5. Test with URI
export LIBVIRT_DEFAULT_URI="qemu:///system"
virsh list --allAfter applying these fixes, virsh list --all should work without sudo. If the issue persists, the problem might be specific to your Debian 13 ARM setup (e.g., a bug or missing package).
Vibe can make mistakes. Check answers. Learn more