Ops, missed this one. It works like a charm.
Now I feel like I'm trying to reinvent the wheel. It's a lot simpler working directly with libvirt.
Thanks a lot for you help.
virsh exposes the libvirt API; if you can't get it working in virsh,On 05/11/2012 03:51 PM, Antonio Carlos Salzvedel Furtado Junior wrote:
> Thanks for the prompt response, it cleared a lot of my doubts
>
> Actually, I could enable the other controllers. It's just that I have a
> strong reason to use the cpu controller.
> I need to set a hard limit for CPU consumption. Maybe 'cpu.shares' was a
> bad example.
> I'm working especially with two parameters, "cpu.cfs_period_us" and
> "cpu.cfs_quota_us". For instance, sometimes I need to limit my VM to 20% of
> the CPU share, regardless of the CPU load. Then I set
> "cpu.cfs_period_us=100000" and "cpu.cfs_quota_us=20000".
> I'm using the libcgroup API to do that, but I agree that it would be better
> to use the libvirt API.
>
> Looking at the documentation, The parameters I'd need to change would be
> the following:
>
> <domain>
> ...
> <cputune>
> <period>100000</period>
> <quota>20000</quota>
> </cputune>
> ...
> </domain>
>
> Unfortunately, I think virsh does not have tools to change these
> parameters, as libcgroup does ( cgget and cgset ). However I guess it won't
> be a problem, I'll try to use the libvirt API.
that's a bug that we should fix. That said:
virsh schedinfo $dom --set vcpu_period=100000 --set vcpu_quota=20000
should do exactly what you're asking for.