Bug 1211548

Summary: memtune settings in running vm xml will disappear after restart libvirtd
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, fjin, honzhang, jtomko, mzhan, rbalakri, shyu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.15-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:28:21 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-04-14 09:56:53 UTC
Description of problem:
memtune settings in xml will disappear after restart libvirtd

Version-Release number of selected component (if applicable):
libvirt-1.2.14-1.el7.x86_64
qemu-kvm-rhev-2.2.0-8.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare a running vm:

# virsh list
 Id    Name                           State
----------------------------------------------------
 9     test4                          running

2. no memtune settings
# virsh memtune test4
hard_limit     : unlimited
soft_limit     : unlimited
swap_hard_limit: unlimited

3. set a big memtune value then recheck:

# virsh memtune test4 --hard-limit 9007199254740988

# virsh dumpxml test4
<domain type='kvm' id='9'>
  <name>test4</name>
  <uuid>b1e7936b-104b-430e-9211-d6c61b8df313</uuid>
  <memory unit='KiB'>1024000</memory>
  <currentMemory unit='KiB'>1024000</currentMemory>
  <memtune>
    <hard_limit unit='KiB'>900719925</hard_limit>
  </memtune>

# virsh memtune test4
hard_limit     : 900719925
soft_limit     : unlimited
swap_hard_limit: unlimited

4. restart libvirtd and recheck:

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

# virsh memtune test4
hard_limit     : 900719925
soft_limit     : unlimited
swap_hard_limit: unlimited

# virsh dumpxml test4
<domain type='kvm' id='9'>
  <name>test4</name>
  <uuid>b1e7936b-104b-430e-9211-d6c61b8df313</uuid>
  <memory unit='KiB'>1024000</memory>
  <currentMemory unit='KiB'>1024000</currentMemory>
  <vcpu placement='static'>5</vcpu>                     <------no memory tune


Actual results:
big memtune value settings will disappear after restart libvirtd,
this will influence migration

Expected results:
still exist

Additional info:

From Shanzhi Yu:

seem we need a virDomainSaveStatus after succeed set memory

qemuDomainSetMemoryParameters(virDomainPtr dom,
 
 #undef QEMU_SET_MEM_PARAMETER
 
+    if (flags & VIR_DOMAIN_AFFECT_LIVE &&
+        virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+        goto endjob;
+

Comment 1 Ján Tomko 2015-04-14 12:20:35 UTC
Fixed upstream by:
commit 1db6212331c6cd9cd0213f60c9ac73effd1fe3ad
Author:     Shanzhi Yu <shyu>
AuthorDate: 2015-04-14 18:24:41 +0800
Commit:     Ján Tomko <jtomko>
CommitDate: 2015-04-14 13:50:08 +0200

    qemu: save domain status after set memory parameters
    
    After set memory parameters for running domain, save the change to live
    xml is needed otherwise it will disappear after restart libvirtd.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211548
    Signed-off-by: Shanzhi Yu <shyu>
    Signed-off-by: Ján Tomko <jtomko>

git describe: v1.2.14-146-g1db6212

Comment 3 Fangge Jin 2015-07-15 03:22:07 UTC
I can reproduce this bug on build libvirt-1.2.14-1.el7.x86_64.

Verify this bug on build libvirt-1.2.17-2.el7.x86_64

Verify steps:
1. prepare a running vm:
# virsh list
 Id    Name                           State
----------------------------------------------------
 19    rhel7-5                        running

2. no memtune settings
# virsh memtune rhel7-5 
hard_limit     : unlimited
soft_limit     : unlimited
swap_hard_limit: unlimited

3. set a big memtune value then recheck:

# virsh memtune rhel7-5 --hard-limit 9007199254740988 

# virsh memtune rhel7-5 
hard_limit     : 9007199254740988
soft_limit     : unlimited
swap_hard_limit: unlimited

# virsh dumpxml rhel7-5
<domain type='kvm' id='19'>
  <name>rhel7-5</name>
  <uuid>ab4696ee-6986-488f-81b8-8578759ae8e2</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <memtune>
    <hard_limit unit='KiB'>9007199254740988</hard_limit>
  </memtune>

4. restart libvirtd and recheck:

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

# virsh memtune rhel7-5 
hard_limit     : 9007199254740988
soft_limit     : unlimited
swap_hard_limit: unlimited

# virsh dumpxml rhel7-5|grep memtune -a5
<domain type='kvm' id='19'>
  <name>rhel7-5</name>
  <uuid>ab4696ee-6986-488f-81b8-8578759ae8e2</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <memtune>
    <hard_limit unit='KiB'>9007199254740988</hard_limit>
  </memtune>

Comment 5 errata-xmlrpc 2015-11-19 06:28:21 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