[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
howtos:emulators:libvirt_config_methods [2022/02/18 19:11 (UTC)] – created zeebrahowtos:emulators:libvirt_config_methods [2023/12/01 12:04 (UTC)] (current) – [Libvirt config, settings and method for Slackware] zeebra
Line 21: Line 21:
 </code> </code>
 Note. You need to log out of X and TTY and back in for group to take effect.\\ Note. You need to log out of X and TTY and back in for group to take effect.\\
-Go to the libvirt config file and uncomment the relevant options and set them correctly. Then start the libvirt daemons.+Go to the libvirt config file and uncomment the relevant options and set them as you prefer. Then start the libvirt daemons.
 <code> <code>
 (as ROOT) (as ROOT)
Line 44: Line 44:
   *run qemu:session   *run qemu:session
   *start libvirt daemons as root   *start libvirt daemons as root
-  *start libvirt daemons and user  +  *start libvirt daemons as user  
-  *to use qemu/kvm through virt-manager+  *to use qemu/kvm through virt-manager in all the above ways
 Personally I only really care about running qemu:session through virt-manager and that's it. But that might not work for others due to networking needs (ex.qemu-vm-server). And if it's a multi user machine it's not a good idea to grant admin rights to everyone in the libvirt group. Some also might not want to give RW rights to kvm. There are many things to consider. Below are some. Personally I only really care about running qemu:session through virt-manager and that's it. But that might not work for others due to networking needs (ex.qemu-vm-server). And if it's a multi user machine it's not a good idea to grant admin rights to everyone in the libvirt group. Some also might not want to give RW rights to kvm. There are many things to consider. Below are some.
  
-=== libvirt.conf === +=== libvirtd.conf === 
-go to the libvirt config file and uncomment the relevant options and set them correctly.+go to the libvirt config file and uncomment the relevant options and set them as you prefer.
 <code> <code>
 nano /usr/local/etc/libvirt/libvirtd.conf nano /usr/local/etc/libvirt/libvirtd.conf
Line 61: Line 61:
  
 The above are internal libvirt settings, while polkit regulates who can use libvirt (sockets) through a GUI like virt-manager for example.\\ The above are internal libvirt settings, while polkit regulates who can use libvirt (sockets) through a GUI like virt-manager for example.\\
-This is ok for a PC with one user where you are the only one in the libvirt group, but you might want to consider less and more strict settings and a different polkit policy.+This is ok for a PC with one user where you are the only one in the libvirt group, but you might want to consider less and more strict settings and a different polkit policy. If you plan to also use LXC or other containers (with libvirt/virt-manager), you need to consider all this more carefully.
  
 === Polkit === === Polkit ===
Line 98: Line 98:
 === kvm === === kvm ===
  
-Running libvirt daemons and qemu:session depends on the step mentioned above involving kvm group and /dev/kvm g+rw. If you want to run things in this way or a similar way you have to write a udev rule to make /dev/kvm group and g+rw permanent.+Running libvirt daemons as user and qemu:session depends on the step mentioned above involving kvm group and /dev/kvm g+rw. If you want to run things in this way or a similar way you have to write a udev rule to make /dev/kvm group and g+rw permanent.
  
-The most "normal" way to run the daemons with kvm/qemu and virt-manager is to run the daemons (on boot) as root and connect to them as user (through libvirt group) and set up a qemu:session. To do that you also need the abovementioned kvm group and settings.+The most common way to run the daemons with kvm/qemu and virt-manager is to run the daemons (on boot) as root and connect to them as user (through libvirt group) and set up a qemu:session. To do that you also need the abovementioned kvm group and settings.
  
 +=== /dev/dri ===
 +
 +The same that applies to kvm also applies to video cards. To solve this, you ONLY need to add the "video" group to your user, if that's the solution you want and think it is a good idea.
 +<code>usermod -aG video username</code>
 +You need to log out of X/wayland and tty, and back in, with your user for this change to take effect.
 +
 +=== /etc/rc.d ===
 +
 +To start libvirtd and virtlogd on boot (as root), you can add them to /etc/rc.d/rc.local:
 +<code>
 +/usr/local/sbin/libvirtd -d
 +/usr/local/sbin/virtlogd -d
 +</code>
 +
 +=== udev ===
 +
 +To change /dev/kvm group and permissions on boot, add a file /etc/udev/rules.d/90-kvm-override.rules and add the following content:\\
 +<code>
 +# /etc/udev/rules.d/90-kvm-override.rules
 +#
 +# Udev rule to override kvm group and permissions:
 +# To allow kvm group read/write access to /dev/kvm
 +#
 +
 +# Set kvm device writable by kvm group
 +KERNEL=="kvm", GROUP:="kvm", MODE:="0660"
 +</code>
 +
 +Once you reboot you can verify the changes:
 +<code>
 +ls -la /dev/kvm
 +crw-rw---- root kvm
 +</code>
 === Appendage === === Appendage ===
  
Line 112: Line 145:
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
 <!-- You must remove the tag-word "template" below before saving your new page --> <!-- You must remove the tag-word "template" below before saving your new page -->
-{{tag>howtos template}}+{{tag>howtos, emulators, qemu, libvirt, kvm, virt-manager}}
 howtos:emulators:libvirt_config_methods ()