Bug 806793

Summary: [RFE]virsh should support '~' ‘$HOME’ in interactive mode
Product: [Community] Virtualization Tools Reporter: zhpeng
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED DEFERRED QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: ajia, crobinso, cwei, dyuan, eblake, mzhan, rbalakri, xen-maint
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-03-23 21:01:34 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 zhpeng 2012-03-26 09:09:30 UTC
Description of problem:
virsh can't use '~' in interactive mode

Version-Release number of selected component (if applicable):
libvirt-client-0.9.10-6.el6.x86_64
libvirt-python-0.9.10-6.el6.x86_64
libvirt-0.9.10-6.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
[root@daisy tmp]# virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # pwd
/tmp

virsh # attach-device rhel6.3 ../root/interface.xml
Device attached successfully

virsh # detach-device rhel6.3 ../root/interface.xml
Device detached successfully

virsh # attach-device rhel6.3 ~/interface.xml
error: Failed to open file '~/interface.xml': No such file or directory

virsh # save rhel6.3 ~/rhel6.3.save
error: Failed to save domain rhel6.3 to ~/rhel6.3.save
error: Failed to create file '/tmp/~/rhel6.3.save': Operation not permitted

virsh # save win2008 $HOME/win2008.save
error: Failed to save domain win2008 to $HOME/win2008.save
error: Failed to create file '/tmp/$HOME/win2008.save': Operation not permitted

virsh # 
Actual results:
virsh do not support '~' ‘$HOME’

Expected results:
support  '~' ‘$HOME’

Additional info:
This kind of usage is very common and many interactive command support this(like ftp)

Comment 1 zhpeng 2012-03-26 09:19:57 UTC
Some info from Eric:
~ expansion is normally done by the shell, but only in certain positions
on the command line.  It might be worth teaching virsh how to do ~
expansion, since those arguments don't fall under the shell's rules.
~ expansion is just shorthand for $HOME.

no-interactive mode works:

[root@zhpeng ~]# virsh save win2008 $HOME/win2008.save

Domain win2008 saved to /root/win2008.save

[root@zhpeng ~]# virsh save win2008 ~/win2008.save

Domain win2008 saved to /root/win2008.save

Comment 4 Cole Robinson 2016-03-23 21:01:34 UTC
eh, I don't know... virsh is not a real shell, $ variables don't work work, you can't pipe, etc. why make an exception for '~' ? if someone provided a patch for this I'm sure we would take it but it doesn't belong in the bug tracker IMO