Bug 806793 - [RFE]virsh should support '~' ‘$HOME’ in interactive mode
Summary: [RFE]virsh should support '~' ‘$HOME’ in interactive mode
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-26 09:09 UTC by zhpeng
Modified: 2016-04-26 18:13 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2016-03-23 21:01:34 UTC
Embargoed:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.