Bug 1183890

Summary: save-image-edit will make spice or vnc passwd disappear when we edit something
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, jtomko, mprivozn, mzhan, pkrempa, rbalakri, zhwang
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.13-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:08:23 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-01-20 06:11:11 UTC
description of problem:
save-image-edit will make spice or vnc passwd disappear when we try to edit it

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

How reproducible:
100%

Steps to Reproduce:
 
1.prepare a running guest with spice passwd

# virsh dumpxml test3 --security-info
    <graphics type='spice' autoport='yes' listen='0.0.0.0' keymap='en-us' passwd='111113'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

2. start and check the passwd work well
# virsh start test3

# virsh dumpxml test3 --security-info
    <graphics type='spice' port='5900' autoport='yes' listen='0.0.0.0' keymap='en-us' passwd='111113'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

3.save guest to file and edit
# virsh save test3 test3.save

Domain test3 saved to test3.save


# virsh save-image-edit test3.save
    <graphics type='spice' autoport='yes' listen='0.0.0.0' keymap='en-us' passwd='111113'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

add a blank line at last (or edit some other things).

State file test3.save edited.


4. passwd will disapear and if we restore the guest will found it is really go away

# virsh save-image-dumpxml test3.save --security-info
    <graphics type='spice' autoport='yes' listen='0.0.0.0' keymap='en-us'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

Actual results:
save-image-edit will make spice or vnc passwd disappear when we edit something

Expected results:
we can edit it success and passwd will work well when we restore the vm
or output a error when we try to edit it and keep the old passwd


Additional info:

Comment 2 Ján Tomko 2015-01-20 12:58:45 UTC
A patch mentioning this bug has been sent upstream:
https://www.redhat.com/archives/libvir-list/2015-January/msg00685.html

Comment 3 Michal Privoznik 2015-01-28 16:26:04 UTC
I've just pushed the patch upstream:

commit f76df311e8896957b92d0e0c5251ee3e6754d9ac
Author:     Luyao Huang <lhuang>
AuthorDate: Tue Jan 20 17:04:41 2015 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Wed Jan 28 16:56:34 2015 +0100

    qemu: fix cannot set graphic passwd via qemuDomainSaveImageDefineXML
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1183890
    
    When we try to update a xml to a image file, we will clear the
    graphics passwd settings, because we do not pass VIR_DOMAIN_XML_SECURE
    to qemuDomainDefCopy, qemuDomainDefFormatBuf won't format the passwd.
    
    Add VIR_DOMAIN_XML_SECURE flag when we call qemuDomainDefCopy
    in qemuDomainSaveImageUpdateDef.
    
    Signed-off-by: Luyao Huang <lhuang>

v1.2.12-30-gf76df31

Comment 5 vivian zhang 2015-05-25 09:14:48 UTC
I can produce this bug with build libvirt-1.2.8-13.el7.x86_64

Verify with build libvirt-1.2.15-2.el7.x86_64

Steps:1

1. edit guest with spice passwd
# virsh edit vm2
...
<graphics type='spice' autoport='yes' listen='0.0.0.0' keymap='en-us' passwd='aaaaaa'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
...

2. start guest and dumpxml --security-info, to check passwd works
# virsh dumpxml vm2 --security-info
...
<graphics type='spice' port='5900' autoport='yes' listen='0.0.0.0' keymap='en-us' passwd='aaaaaa'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
...

3.save guest

# virsh save vm2 vm2.save

Domain vm2 saved to vm2.save

4. edit save file, modify some place
# virsh save-image-edit vm2.save 
State file vm2.save edited.

5. dumpxml save file, check passwd still exist

# virsh save-image-dumpxml vm2.save --security-info
...
<graphics type='spice' autoport='yes' listen='0.0.0.0' keymap='en-us' passwd='aaaaaa'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
...

6. test graphics type=vnc, reproduce step 1-5, get the same result

...
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='en-us' passwd='cccccc'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
...

move to verified

Comment 7 errata-xmlrpc 2015-11-19 06:08:23 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