Red Hat Bugzilla – Bug 854133
libvirt should check the range of emulator_period and emulator_quota when set them with --config
Last modified: 2013-02-21 02:23:06 EST
Description of problem: libvirt should check the range of emulator_period and emulator_quota when set them with --config. Refer to the http://libvirt.org/formatdomain.html#elementsCPUTuning emulator_period - The value should be in range [1000, 1000000]. A period with value 0 means no value. emulator_quota -The value should be in range [1000, 18446744073709551] or less than 0. A quota with value 0 means no value. Version-Release number of selected component (if applicable): libvirt-0.10.1-1.el6.x86_64 qemu-kvm-0.12.1.2-2.305.el6.x86_64 How reproducible: 100% Steps to Reproduce: 1. # virsh start rhel6.2 Domain rhel6.2 started 2.# virsh schedinfo rhel6.2 --set emulator_period=500 --config Scheduler : posix cpu_shares : 0 vcpu_period : 0 vcpu_quota : 0 emulator_period: 500 emulator_quota : 0 3. # virsh schedinfo rhel6.2 --set emulator_quota=500 --config Scheduler : posix cpu_shares : 0 vcpu_period : 0 vcpu_quota : 0 emulator_period: 500 emulator_quota : 500 4. # virsh destroy rhel6.2 Domain rhel6.2 destroyed 5.# virsh start rhel6.2 Domain rhel6.2 started 6.# virsh dumpxml rhel6.2 <domain type='kvm' id='37'> ..... <cputune> <emulator_period>500</emulator_period> <emulator_quota>500</emulator_quota> <vcpupin vcpu='0' cpuset='1'/> <vcpupin vcpu='1' cpuset='2'/> </cputune> ..... </domain> # virsh schedinfo rhel6.2 Scheduler : posix cpu_shares : 1024 vcpu_period : 100000 vcpu_quota : -1 emulator_period: 100000 emulator_quota : -1 Actual results: libvirt doesn't check the range of emulator_period and emulator_quota when set them with --config. Expected results: libvirt should check the range of emulator_period and emulator_quota when set them with --config. Additional info:
Another related issue visible in step 6 is that libvirtd is silently ignoring values in emulator_{period,quota}.
API range checking added upstream with: commit 972e914f59aa90bb727c4b5596e77f7bacdeb703 Author: Peter Krempa <pkrempa@redhat.com> Date: Tue Sep 4 15:17:07 2012 +0200 qemu: Add range checking for scheduler tunables when changed by API The quota and period tunables for cpu scheduler accept only a certain range of values. When changing the live configuration invalid values get rejected. This check is not performed when changing persistent config. This patch adds a separate range check, that improves error messages when changing live config and adds the check for persistent config. This check is done only when using the API. It is still possible to specify invalid values in the XML. The range checking commit exposed a problem in virsh that was updating all tunables not the only that were changed by the user, so if an invalid configuration was present in the XML (that is still lacking range checking) users could not set the new values. This issue is fixed upstream with: commit 51907779ee025e6edf4125cf4b4f35e279e2f6e2 Author: Peter Krempa <pkrempa@redhat.com> Date: Wed Sep 5 14:41:25 2012 +0200 virsh: Update only changed scheduler tunables When setting the cpu tunables in virsh you are able to update only a subset of them. Virsh while doing the update updated all of the tunables, changed ones with new values and unchanged with old ones. This is unfortunate as it: a) might overwrite some other change by a race condition (unprobable) b) fails with range checking as some of the old values saved might be out of range This patch changes the update procedure so that only the changed value is updated on the host. This patch also fixes a very unprobable memory leak if the daemon would return a string tunable parameter, as the typed parameter array was not cleared. I also opened bug https://bugzilla.redhat.com/show_bug.cgi?id=854537 to remind to add range checking also to XML parsing, but that's a more difficult issue. I'm moving this bug to POST, the fix will be picked up by rebasing.
Test with libvirt-0.10.2-0rc1.el6.x86_64. If set emulator_period to an integer(eg. 500, 1000...), the result is correct # virsh schedinfo aaa --set emulator_period=500 --config Scheduler : posix error: invalid argument: value of 'emulator_period' is out of range [1000, 1000000] # virsh schedinfo aaa --set emulator_period=1234 --config Scheduler : posix cpu_shares : 0 vcpu_period : 0 vcpu_quota : 0 emulator_period: 1234 emulator_quota : 0 but when set emulator_period to invalid value(such as 'aaa'), the result is: # virsh schedinfo aaa --set emulator_period=aaa --config Scheduler : posix and i think it also need check, right? For emulator_period, the result is same with emulator_period.
The error isn't propagated to virsh when the value of the updated argument is not valid. I opened https://bugzilla.redhat.com/show_bug.cgi?id=882915 to track this issue.
(In reply to comment #6) > The error isn't propagated to virsh when the value of the updated argument > is not valid. I opened https://bugzilla.redhat.com/show_bug.cgi?id=882915 to > track this issue. OK, then this bug can move to VERIFIED.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2013-0276.html