Configuring Libvirt
Now that we've got the packages installed, you might notice that when you try to open virt-manager
, it asks for the root password. To smooth things out, we'll need to configuring libvirt, qemu, and virt-manager for adjust permissions so everything runs more seamlessly.
Adjust Permissions for virt-manager
Here’s how to set up your system so you can use virt-manager
without constantly needing root access:
-
Open the configuration file with:
sudo vim /etc/libvirt/libvirtd.conf
-
Look for the
unix_sock_group
andunix_sock_rw_perms
entries in the file. Uncomment these lines and set the values as shown below:-
Set
unix_sock_group
tolibvirt
:unix_sock_group = "libvirt"
-
Set
unix_sock_rw_perms
to0770
to allow the right permissions forvirt-manager
:unix_sock_rw_perms = "0770"
-
-
Save and exit by typing
:wq
.
This configuration will let you launch and manage virt-manager
without running into permission problems.
Set Up Logging for Troubleshooting (Optional but Recommended)
If you run into issues with virt-manager
, having logs can be a lifesaver. To set up logging:
-
Open the
/etc/libvirt/libvirtd.conf
file again:sudo vim /etc/libvirt/libvirtd.conf
-
Add these lines at the end of the file to set up logging:
log_filters="3:qemu 1:libvirt"
log_outputs="2:file:/var/log/libvirt/libvirtd.log"
This way, you’ll have detailed logs to help troubleshoot any problems.
Add Your User to the libvirt
Group
To use virt-manager
without any superuser warnings, add your user to the libvirt
and kvm
groups:
- Run the following command:
sudo usermod -a -G kvm,libvirt $(whoami)
Enable and Start Libvirt Services
Make sure libvirt services start automatically on boot and then start the libvirt service:
sudo systemctl enable libvirtd
sudo systemctl start libvirtd
Verify Group Membership
Check that your user has been added to the necessary groups:
sudo groups $(whoami)
This confirms that you’ve successfully added your user to the libvirt
and kvm
groups.
QEMU Configuration
To make sure QEMU processes run with your user permissions:
-
Edit the
qemu.conf
file:sudo vim /etc/libvirt/qemu.conf
Tip: In
vim
, you can quickly finduser =
by pressing/
, typinguser =
, and pressingEnter
. -
Look for these lines:
user = "libvirt"
group = "libvirt" -
Change
"libvirt"
to your username:user = "username"
group = "username"
This adjustment ensures QEMU processes run with your user privileges.
Restart the libvirtd
Service
Apply your changes by restarting the libvirtd
service:
sudo systemctl restart libvirtd
Start virsh
Network Automatically - (Optional but Recommended)
If you only want to passthrough your LAN or wireless, ignore it's ok.
Every standard libvirt installation provides NAT based connectivity to virtual machines out of the box. This is the so called default virtual network
.
For more: https://wiki.libvirt.org/Networking.html
sudo virsh net-autostart default
Now, you’ve configured permissions, added your user to the right groups, QEMU settings, and ensured services are running correctly.
What’s Next?
Now it’s time to download the ISO files for the operating systems you’ll be using.