Bug 1260576

Summary: guest which use big maxmemory will lose track after restart libvirtd
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, mzhan, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:23:20 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 Luyao Huang 2015-09-07 09:49:58 UTC
Description of problem:
guest which use big maxmemory will lose track after restart libvirtd

Version-Release number of selected component (if applicable):
libvirt-1.2.17-7.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare a guest with 9007199254740991kib maxmem
# virsh dumpxml rhel7.0-rhel
<domain type='kvm'>
  <name>rhel7.0-rhel</name>
  <uuid>67c7a123-5415-4136-af62-a2ee098ba6cd</uuid>
  <maxMemory slots='16' unit='KiB'>9007199254740991</maxMemory>


2. start it:
# virsh start rhel7.0-rhel
Domain rhel7.0-rhel started

# virsh list
 Id    Name                           State
----------------------------------------------------
 21    rhel7.0-rhel                   running


3. restart libvirtd recheck:

# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service

# virsh list
 Id    Name                           State
----------------------------------------------------

and can find log in libvirtd.log

2015-09-07 09:46:04.280+0000: 3839: error : virScaleInteger:337 : numerical overflow: value too large: 9007199254740992KiB


Actual results:
guest which use big maxmemory will lose track after restart libvirtd, libvirt 
call qemuDomainAlignMemorySizes change 9007199254740991 to 9007199254740992

Expected results:
guest still exist after restart libvirtd or get failure when start guest

Additional info:

Comment 1 Peter Krempa 2015-12-04 14:29:45 UTC
commit 645881139b3d2c86acf9d644c3a1471520bc9e57
Author: Peter Krempa <pkrempa>
Date:   Tue Dec 1 14:08:37 2015 +0100

    qemu: domain: Prevent overflows in memory alignment code
    
    Since libvirt for dubious historical reasons stores memory size as
    kibibytes, it's possible that the alignments done in the qemu code
    overflow the the maximum representable size in bytes. The XML parser
    code handles them in bytes in some stages. Prevent this by doing
    overflow checks when alinging the size and add a test case.

Comment 3 Luyao Huang 2016-06-01 09:40:47 UTC
Verify this bug with libvirt-1.3.4-1.el7.x86_64:

1. prepare a inactive guest:

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     rhel72-test                    shut off

2. change guest maxmemory to 9007199254740991KiB:

# virsh dumpxml rhel72-test |grep max
  <maxMemory slots='16' unit='KiB'>9007199254740991</maxMemory>

3. start guest:

# virsh start rhel72-test
error: Failed to start domain rhel72-test
error: unsupported configuration: maximum memory size overflowed after alignment

4. change guest memory to 9007199254740991KiB:

# virsh dumpxml rhel72 |grep emory
  <memory unit='KiB'>9007199254740991</memory>
  <currentMemory unit='KiB'>9007199254740991</currentMemory>

5. start guest

# virsh start rhel72
error: Failed to start domain rhel72
error: unsupported configuration: initial memory size overflowed after alignment

6. test guest used a maxmemory which won't cause overflowed problem:

# virsh dumpxml rhel72-test |grep max
  <maxMemory slots='16' unit='KiB'>9007199254739968</maxMemory>

# virsh start rhel72-test
Domain rhel72-test started

# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 51    rhel72-test                    running

Comment 5 errata-xmlrpc 2016-11-03 18:23:20 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/RHSA-2016-2577.html