[libvirt] limit cpu speed in domain xml

Martin Kletzander mkletzan at redhat.com
Thu Mar 16 06:43:47 UTC 2017


On Thu, Mar 16, 2017 at 12:14:31AM +0300, Vasiliy Tolstov wrote:
>Hi. Does it possible to limit vm cpu speed for example to 1Ghz or 500Mhz ?
>I need to simulate some hardware with specific cpu speed and test my
>application inside this vm , i want to measure results from each test
>and need constant cpu speed for testing (i need to run test not only
>my notebook but on server too and want identical cpu speed inside vm)
>

You can set how much time the VM gets (i.e. limit it), but I'm not sure
to what extent will that guarantee stable speed.  Unfortunately, there
is no way to tell QEMU what the frequency should be in the guest
either.  I don't think it's possible in KVM.

You could, _theoretically_, pin the domain to a specific physical CPUs,
and force a specific frequency of those pCPUs using cpufreq.

If you are concerned with the speeds, you should also make sure you
expose exactly the same CPU model to the guest.  Anyway, I would be very
careful with interpreting the results in any case.

Martin

P.S.: I always wondered if I could somehow tell QEMU to advertise slower
      frequency to the guest.  I would even have some use cases for
      that, I think.  If somebody knows, tell me ;)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170316/bec82cd7/attachment-0001.sig>


More information about the libvir-list mailing list