Bug 1122205

Summary: 'virsh desc $dom blah' doesn't survive libvirtd restart
Product: Red Hat Enterprise Linux 6 Reporter: Eric Blake <eblake>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6CC: dyuan, eblake, jdenemar, jsuchane, lhuang, rbalakri, rbian, tlavigne, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.10.2-45.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1122255 (view as bug list) Environment:
Last Closed: 2014-10-14 04:23:15 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:
Bug Depends On: 1115039    
Bug Blocks: 1122255    

Description Eric Blake 2014-07-22 18:53:06 UTC
Description of problem:
I noticed this while reviewing bug 1115039, although the issue is independent. By itself, virDomainSetMetadata doesn't save active XML changes to disk; if no other command is issued which also saves to disk, then the edits are lost across libvirtd restarts.

Version-Release number of selected component (if applicable):
libvirt-0.10.2-41.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start a new transient domain with a known description "desc1" (in build -42, you can omit the description, but in build -41, description has to exist or libvirtd will crash)
2. modify the description: virsh desc $dom desc2
3. check the description: virsh dumpxml $dom | grep desc
4. restart libvirtd: service libvirtd restart
5. check the description: virsh dumpxml $dom | grep desc
6. try again: virsh desc $dom desc3
7. this time, force xml saves: virsh suspend $dom
8. restart libvirtd: service libvirtd restart
9. check the description: virsh dumpxml $dom | grep desc

Actual results:
3.   <description>desc2</description>
5.   <description>desc1</description>
9.   <description>desc3</description>

Expected results:
3.   <description>desc2</description>
5.   <description>desc2</description>
9.   <description>desc3</description>


Additional info:

Comment 1 Eric Blake 2014-07-22 19:12:01 UTC
Upstream patch proposed:
https://www.redhat.com/archives/libvir-list/2014-July/msg01150.html

Comment 2 Eric Blake 2014-07-23 16:15:15 UTC
During review, Martin pointed out that at qemuDomainSetNumaParameters() probably has the same issue.  There are probably other broken APIs, it may be worth a full audit, and maybe retitling this bug to cover all of the APIs that don't save state to disk after modifying in-memory XML.

Comment 5 Luyao Huang 2014-08-15 08:02:47 UTC
I have found some virsh command have this issue:
1.blkiotune --device-weights
steps for reproduce:
 1.# virsh blkiotune test6
  weight         : 1000
  device_weight  : /dev/sda,1000
 2.# virsh dumpxml test6|grep -2 /dev/sda
  <blkiotune>
    <device>
      <path>/dev/sda</path>
      <weight>1000</weight>
    </device>

 3.# virsh blkiotune test6 --device-weights /dev/sda,0

 4.# virsh blkiotune test6
  weight         : 1000
  device_weight  : 
 5.# virsh dumpxml test6|grep -2 /dev/sda

 6.# service libvirtd restart
  Stopping libvirtd daemon:                                  [  OK  ]
  Starting libvirtd daemon:                                  [  OK  ]
 7.# virsh blkiotune test6
  weight         : 1000
  device_weight  : /dev/sda,1000
 8.# virsh blkiotune test6 --device-weights /dev/sda,0
 9.# virsh suspend test6
  Domain test6 suspended
 10.# service libvirtd restart
  Stopping libvirtd daemon:                                  [  OK  ]
  Starting libvirtd daemon:                                  [  OK  ]
 11.# virsh dumpxml test6|grep -2 /dev/sda

 12.# virsh blkiotune test6
  weight         : 1000
  device_weight  : 

2.numatune --nodeset(seems this command use qemuDomainSetNumaParameters)
steps for reproduce just like blkiotune

3.migrate-setspeed
steps for reproduce just like blkiotune

4.domiftune 
steps for reproduce just like blkiotune

Comment 10 Luyao Huang 2014-09-05 06:30:19 UTC
I can reprodeuce it with libvirt-0.10.2-41.el6.x86_64
Verify this bug with libvirt-0.10.2-45.el6.x86_64.

Step:
For disc:
# virsh desc r6 1234
Domain description updated successfully
# virsh desc r6
1234
# virsh dumpxml r6|grep  description
  <description>123</description>

# service libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]

# virsh desc r6
1234

# virsh dumpxml r6|grep description
  <description>123</description>

For metadata:
use rhel7 to connect to rhel6
virsh # metadata test6 --uri http://herp.derp/ --key herp --set  "<derp xmlns:foobar='http://foo.bar/'></derp>"
Metadata modified

virsh # metadata test6 --uri http://herp.derp/ --live
<derp xmlns:foobar="http://foo.bar/"/>

virsh # dumpxml test6
  <metadata>
    <herp:derp xmlns:foobar="http://foo.bar/" xmlns:herp="http://herp.derp/"/>
  </metadata>



restart libvirtd in rhel6
# service libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]


virsh # metadata test6 --uri http://herp.derp/ --live
<derp xmlns:foobar="http://foo.bar/"/>

virsh # dumpxml test6
  <metadata>
    <herp:derp xmlns:foobar="http://foo.bar/" xmlns:herp="http://herp.derp/"/>
  </metadata>

Comment 12 errata-xmlrpc 2014-10-14 04:23:15 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/RHBA-2014-1374.html