RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 854133 - libvirt should check the range of emulator_period and emulator_quota when set them with --config
Summary: libvirt should check the range of emulator_period and emulator_quota when set...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 854536 854537
TreeView+ depends on / blocked
 
Reported: 2012-09-04 07:10 UTC by hongming
Modified: 2013-02-21 07:23 UTC (History)
8 users (show)

Fixed In Version: libvirt-0.10.2-0rc1.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 854536 854537 (view as bug list)
Environment:
Last Closed: 2013-02-21 07:23:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0276 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2013-02-20 21:18:26 UTC

Description hongming 2012-09-04 07:10:44 UTC
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:

Comment 2 Jiri Denemark 2012-09-04 07:46:40 UTC
Another related issue visible in step 6 is that libvirtd is silently ignoring values in emulator_{period,quota}.

Comment 3 Peter Krempa 2012-09-07 06:26:38 UTC
API range checking added upstream with:

commit 972e914f59aa90bb727c4b5596e77f7bacdeb703
Author: Peter Krempa <pkrempa>
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>
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.

Comment 5 yanbing du 2012-09-20 09:55:36 UTC
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.

Comment 6 Peter Krempa 2012-12-03 10:53:47 UTC
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.

Comment 7 yanbing du 2012-12-04 02:36:26 UTC
(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.

Comment 8 errata-xmlrpc 2013-02-21 07:23:06 UTC
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


Note You need to log in before you can comment on or make changes to this bug.