Bug 1140958

Summary: check the value of memory statistic period in xml
Product: Red Hat Enterprise Linux 7 Reporter: Jincheng Miao <jmiao>
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, eskultet, honzhang, lhuang, mkletzan, mzhan, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.14-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:46:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jincheng Miao 2014-09-12 06:31:37 UTC
Description of problem:
virsh command dommemstat forbids converting a large integer to signed one,
but this rule is not applied for configuration xml. The user could still set such
large value to virtio memballoon statistic period.
So libvirtd should check this value in xml.

Version-Release number of selected component (if applicable):
libvirt-1.2.8-1.el7.x86_64
qemu-kvm-rhev-2.1.0-3.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. configure guest with virtio memballoon statistic period '4294967295' (known as (int)-1):
# virsh dumpxml r7a | grep -1 memballoon
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
      <stats period='4294967295'/>
    </memballoon>
  </devices>

2. start guest
# virsh start r7a
Domain r7a started

the qmp event reports the error of this statistic period:
4865.707 > 0x7fd9f80077d0 {"execute":"qom-set","arguments":{"path":"//machine/i440fx/pci.0/child[9]","property":"guest-stats-polling-interval","value":-1},"id":"libvirt-88"}
4865.708 < 0x7fd9f80077d0 {"id": "libvirt-88", "error": {"class": "GenericError", "desc": "timer value must be greater than zero"}}

Expect result:
Don't convert '4294967295' to -1, or forbid user to set this value to '4294967295'.

Comment 2 Erik Skultety 2014-10-08 13:05:21 UTC
Fixed upstream:

commit e3a7b8740fb4be15d9ba4f49f65bb9ee743730a0
Author: Erik Skultety <eskultet>
Date:   Thu Oct 2 14:48:02 2014 +0200

    qemu: Fix updating balloon period in live XML
    
    Up until now, we set memballoon period in monitor successfully, however
    we did not update domain definition structure, thus dumpxml was omitting
    period attribute in memballoon element

v1.2.9-12-ge3a7b87

Comment 3 Erik Skultety 2014-10-10 11:46:25 UTC
EDIT: The commit I posted above is a related to a different issue (I'm sorry for my mistake), therefore this bug still needs to be considered as unfixed!!!

Comment 5 Luyao Huang 2015-03-13 09:19:52 UTC
Post a patch to upstream wait review:

http://www.redhat.com/archives/libvir-list/2015-March/msg00665.html

Comment 7 Erik Skultety 2015-03-24 11:31:31 UTC
commit ad69e8be4a7592c68174a7c0d8b07a2c392ea336
Author: Martin Kletzander <mkletzan>
Date:   Fri Mar 13 17:08:15 2015 +0100

    conf: Use correct type for balloon stats period
    
    We're parsing memballoon status period as unsigned int, but when we're
    trying to set it, both we and qemu use signed int.  That means large
    values will get wrapped around to negative one resulting in error.
    Basically the same problem as commit e3a7b874 was dealing with when
    updating live domain.
    
    QEMU changed the accepted value to int64 in commit 1f9296b5, but even
    values as INT_MAX don't make sense since the value passed means seconds.
    Hence adding capability flag for this change isn't worth it.

v1.2.13-203-gad69e8b

Comment 10 Luyao Huang 2015-07-22 02:04:55 UTC
Verify this bug in libvirt-1.2.17-2.el7.x86_64:

1. edit a guest and add period [2147483648, 4294967295] in memory balloon:

# virsh edit test4

    <memballoon model='virtio'>
      <stats period='4294967295'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'/>
    </memballoon>

2. recheck the xml:

# virsh dumpxml test4 --inactive |grep period

3.test update libvirt from libvirt-1.2.13-1.el7.x86_64 to libvirt-1.2.17-2.el7.x86_64 with a invalid period:

# virsh dumpxml test4 --inactive |grep period
      <stats period='4294967295'/>

# yum update /mnt/rhel7/libvirt/1.2.17-2.el7/libvirt-* /mnt/rhel7/libvirt-python/1.2.17-1.el7/libvirt-python-*

# virsh dumpxml test4 --inactive |grep period

Comment 12 errata-xmlrpc 2015-11-19 05:46:44 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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html