[libvirt-users] Running all my virtual machines with a low priority

Martin Kletzander mkletzan at redhat.com
Thu May 2 11:48:06 UTC 2019


On Thu, May 02, 2019 at 12:10:54PM +0200, R. Diez wrote:
>
>> You could perhaps set  'cpu.shares' cgroup setting on /machine.slice.
>> This isn't really a nice level in the traditional sense, rather it is
>> a relative weighting evaluated against other cgroups at the same level.
>> So if you change it from 1024 to 512, then processes under /machine.slice
>> will get 1/2 the CPU time vs stuff under /system.slice or /user.slice,
>> when there is contention for CPU time.
>
>Thanks for your help.
>
>There is no "machine.slice" on my system. This is an excerpt from "systemd-cgls".
>
>
>??? ??????system.slice
>???   ??????irqbalance.service
>???   ??? ??????865 /usr/sbin/irqbalance --foreground
>[... blah blah ...]
>???   ??????wpa_supplicant.service
>???   ??? ??????878 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
>???   ??????libvirtd.service
>???   ??? ??????  987 /usr/sbin/libvirtd
>???   ??? ?????? 1395 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro
>--dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
>???   ??? ?????? 1396 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro
>--dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
>???   ??? ??????12285 /usr/bin/qemu-system-x86_64 -name guest=UbuntuMATE1804,debug-threads=on -S -object
>secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-UbuntuMATE1804/master-key.aes -machine...
>

Runing:

  $ systemctl set-property machine.slice CPUShares=512

works for me on some random machine I tried.  As far as I understand, Nice= was
supported (for backward compatibility) but it is not now, or at least not for
slices.

Feel free to set other things with similar commands or just use systemctl edit
machine.slice and configure that however you want.  Looking for the proper
documentation is left as an exercise for the reader.

>
>But I guess there are differences depending on the libvirt version.
>
>I thought of 'nice' because it is an easy way to lower the priority for everything (CPU and disk) at once.
>
>This is actually getting too complicated. I am a lone developer and sysadmin in a small company. I would need to learn too many things about
>control groups etc. One of the reasons I am trying libvirt is because of the "Virtual Machine Manager" GUI.
>

I believe such basic settings should *not* be complicated, and I hope the above
got you closer to the goal.

>Is there not an easier way? I realised there is a "libvirtd.service" on my system. Is there a simple way in systemd to just lower the
>priority of everything under that service? I am assuming that this service is starting all the virtual machines.
>

We are also counting with the use case where you want the machine to take full
advantage of the system and its resources, but you want to restrict the
management of such virtual machines (libvirt in this case), so libvirt has to
explicitly override any possibly inherited configuration for virtual machines it
is starting.  That's why setting anything on the libvirtd.service will not work.

>Best regards,
>   rdiez
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20190502/4d34845d/attachment.sig>


More information about the libvirt-users mailing list