[libvirt] [PATCH] virsh: Fix a problem of argv parsing

Eric Blake eblake at redhat.com
Tue Apr 12 21:30:27 UTC 2011


On 04/05/2011 06:38 AM, Osier Yang wrote:
> Problem example:
>   # virsh -d 5 vol-create --pool default col.xml
>   vol-create: pool(optdata): default
>   vol-create: pool(optdata): col.xml
>   error: command 'vol-create' requires <file> option
> 
>   It gets same "vshCmdOptDef" for both "--pool default"
>   and "col.xml".
> 
> This patch fixes it by increase "data_ct" when things like
> "--pool default" is successfully parsed, so that could
> get right "vshCmdOptDef" for the other arguments which
> are not with option name together.
> ---
>  tools/virsh.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)

NAK to this patch.  It still doesn't detect other issues with argument
parsing, such as 'virsh vol-create --pool default --pool other col.xml'.
 Typically, option parsing should favor the last instance of a given
option, rather than the first, or error out that the option is given too
many times, but your patch doesn't change the status quo of going with
the first instance of the option.

Instead, I've prepared a better patch that not only fixes this issue,
but also addresses a regression I introduced in 0.8.5, where 'virsh
freecell 0' no longer parses correctly.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110412/9ff2457c/attachment-0001.sig>


More information about the libvir-list mailing list