Bug 602277

Summary: Can 'virsh edit' append a '.xml' suffix to tempfile edited by vim?
Product: Red Hat Enterprise Linux 6 Reporter: Kirby Zhou <kirbyzhou>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: ccui, dallan, dyuan, jdenemar, llim, mzhan, xen-maint
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.8.6-1.el6 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-19 13:19:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kirby Zhou 2010-06-09 14:12:29 UTC
Description of problem:

Can 'virsh edit' append a '.xml' suffix to tempfile edited by vim?
So vim can recognize the tmepfile as a xml file and set filetype=xml for it.

Version-Release number of selected component (if applicable):

libvirt-0.7.6-2.el6.x86_64

Comment 2 RHEL Program Management 2010-06-09 14:32:57 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.

Comment 3 Jiri Denemark 2010-06-14 15:31:16 UTC
This could probably be implemented upstream quite easily using gnulib's mkstemps instead of starndard mkstemp which doesn't support suffixes in temp files. However, I'm not sure if this is anything we can easily do for rhel6.

Although, it's something which can be worked around by configuring vim to detect all /tmp/virsh* files as XML files.

Comment 6 Jiri Denemark 2010-11-09 13:37:52 UTC
This is now committed upstream as fb76151c28df0fa07a35219ae7455cefd1c41199

Comment 7 Jiri Denemark 2010-11-17 14:46:38 UTC
Fixed in v0.8.5-50-gfb76151 upstream:

commit fb76151c28df0fa07a35219ae7455cefd1c41199
Author: Jiri Denemark <jdenemar>
Date:   Tue Nov 9 10:27:09 2010 +0100

    virsh: Add .xml suffix to tmp files used in *edit commands
    
    This helps editors with detecting the temporary files as XML since the
    temporary files do not contain <?xml ...?> declaration.
    
    Requested by https://bugzilla.redhat.com/show_bug.cgi?id=602277

Comment 8 Jiri Denemark 2010-12-23 23:48:30 UTC
Fixed by a rebase to libvirt-0.8.6

Comment 9 Cui Chun 2010-12-24 09:51:59 UTC
Verified it. Passed.

Test enviorment:
    RHEL6,
    kernel-2.6.32-92.el6, 
    qemu-kvm-0.12.1.2-2.128.el6, 
    libvirt-0.8.6-1.el6


Steps:

1. Check the domain
  # virsh list 
 Id Name                 State
 ----------------------------------
  1 graph                running
  2 qcow2                running
 
2. Edit domain
  # virsh edit graph
  The file "/tmp/virsh3RespQ.xml" can be shown correctly. 

3. Check the domain configration with .xml suffix from /tmp during run "virsh edit".
   The domain configration with .xml suffix can be listed and opened correctly.

4. Check the domain configration with .xml suffix from /tmp after exit "virsh edit".
    The domain configration with .xml suffix can be removed.

5. Repeat step 1-4 on libvirt-0.8.1-27.el6
    The domain configration didn't includ .xml suffix

Comment 11 Cui Chun 2011-02-09 06:40:58 UTC
Rechecked it on the following test environment according to comment 9. It is passed.

Test environment:
libvirt-0.8.7-5.el6
qemu-kvm-0.12.1.2-2.144.el6
kernel-2.6.32-94.el6

Comment 14 errata-xmlrpc 2011-05-19 13:19:07 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0596.html