Ops, missed this one. It works like a charm.<br>Now I feel like I'm trying to reinvent the wheel. It's a lot simpler working directly with libvirt.<br><br>Thanks a lot for you help.<br><br><div class="gmail_quote">

On Fri, May 11, 2012 at 7:04 PM, Eric Blake <span dir="ltr"><<a href="mailto:eblake@redhat.com" target="_blank">eblake@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5">On 05/11/2012 03:51 PM, Antonio Carlos Salzvedel Furtado Junior wrote:<br>
> Thanks for the prompt response, it cleared a lot of my doubts<br>
><br>
> Actually, I could enable the other controllers. It's just that I have a<br>
> strong reason to use the cpu controller.<br>
> I need to set a hard limit for CPU consumption. Maybe 'cpu.shares' was a<br>
> bad example.<br>
> I'm working especially with two parameters, "cpu.cfs_period_us" and<br>
> "cpu.cfs_quota_us". For instance, sometimes I need to limit my VM to 20% of<br>
> the CPU share, regardless of the CPU load. Then I set<br>
> "cpu.cfs_period_us=100000" and "cpu.cfs_quota_us=20000".<br>
> I'm using the libcgroup API to do that, but I agree that it would be better<br>
> to use the libvirt API.<br>
><br>
> Looking at the documentation, The parameters I'd need to change would be<br>
> the following:<br>
><br>
> <domain><br>
>   ...<br>
>   <cputune><br>
>     <period>100000</period><br>
>     <quota>20000</quota><br>
>   </cputune><br>
>   ...<br>
> </domain><br>
><br>
> Unfortunately, I think virsh does not have tools to change these<br>
> parameters, as libcgroup does ( cgget and cgset ). However I guess it won't<br>
> be a problem, I'll try to use the libvirt API.<br>
<br>
</div></div>virsh exposes the libvirt API; if you can't get it working in virsh,<br>
that's a bug that we should fix.  That said:<br>
<br>
virsh schedinfo $dom --set vcpu_period=100000 --set vcpu_quota=20000<br>
<br>
should do exactly what you're asking for.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Eric Blake   <a href="mailto:eblake@redhat.com">eblake@redhat.com</a>    <a href="tel:%2B1-919-301-3266" value="+19193013266">+1-919-301-3266</a><br>
Libvirt virtualization library <a href="http://libvirt.org" target="_blank">http://libvirt.org</a><br>
<br>
</div></div></blockquote></div><br>