[libvirt] [PATCH] vsh: print help more often
John Ferlan
jferlan at redhat.com
Wed Oct 21 11:35:34 UTC 2015
On 10/21/2015 07:23 AM, Michal Privoznik wrote:
> On 21.10.2015 13:19, Peter Krempa wrote:
>> On Wed, Oct 21, 2015 at 10:48:13 +0200, Michal Privoznik wrote:
>>> So, consider following scenario:
>>>
>>> virsh # migrate --help
>>>
>>> In this case migrate help is printed out. So far so good.
>>> However, you start writing this long migrate command (I bet you
>>> know the arguments there can get quite long), but then, at some
>>> point you need to print out the help. Something like this:
>>>
>>> virsh # migrate --copy-storage-all --migrate-disks --help
>>>
>>> In this specific case you just want to see the format that
>>> --migrate-disks accepts. So you append --help and expect help to
>>> be printed out. Well, it will not, because "--help" is taken as
>>> data to --migrate-disks. Therefore we will get this error
>>> instead:
>>>
>>> virsh # migrate --copy-storage-all --migrate-disks --help
>>> error: command 'migrate' requires <domain> option
>>> error: command 'migrate' requires <desturi> option
>>>
>>> Teach our parsing code, that --help may occur even in argument
>>> data, and therefore anywhere on the command line.
>>>
>>> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>>> ---
>>> tools/vsh.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>
>> The following then won't be possible:
>>
>> $ virsh start --domain --help
>> Domain --help started
>>
>> $ virsh list
>> Id Name State
>> ----------------------------------------------------
>> 2 --help running
>>
>> $ virsh destroy --domain --help
>> Domain --help destroyed
>>
>>
>> If you are curious whether such config is actually valid ...
>>
>> # virt-xml-validate /etc/libvirt/qemu/--help.xml
>> /etc/libvirt/qemu/--help.xml validates
>>
>> Since the schema looks like:
>> <define name="domainName">
>> <data type="string">
>> <!-- Use literal newline instead of \n for bug in libxml2 2.7.6 -->
>> <param name="pattern">[^
>> ]+</param>
>> </data>
>> </define>
>>
>> Peter
>>
>
>
> Well, I'd say <not_personal>if you are that stupid to call your domain
> like that, you should suffer</not_personal>, but I don't care that much
> if this patch goes in or not.
>
Well for someone that wants to name their domain '--help', we could
require they escape it first - eg '\--help'.
Alternatively, can "--?" be used instead? Or is it felt someone would
name their domain that too?
John
More information about the libvir-list
mailing list