Bug 1213274 - Improve the misunderstanding error messages of virt-tar-in/virt-tar-out/virt-copy-in/virt-copy-out
Summary: Improve the misunderstanding error messages of virt-tar-in/virt-tar-out/virt-...
Keywords:
Status: NEW
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-20 08:47 UTC by Lingfei Kong
Modified: 2021-04-19 10:35 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-19 20:53:03 UTC
Embargoed:


Attachments (Terms of Use)

Description Lingfei Kong 2015-04-20 08:47:56 UTC
Description of problem:
At some situations, virt-tar-in/virt-tar-out/virt-copy-in/virt-copy-out will output some misunderstanding error messages due to the simple wrapper around the guestfish. I have wrote another simple wrapper to guestfish, it can improve this situation and give a proper error message. I have tested this version of wrapper, it works well, it can also used to virt-tar-out/virt-copy-in/virt-copy-out. Here is the new wrapper:

base_name="$(basename $0)"
requiredarg()
{
    [ -z "$2" ] && {
        echo "$base_name: option requires an argument -- '${1//-/}'" >&2
        echo "Try \`$base_name --help' for more information." >&2
        exit
    }
    
    add_disk="$1 $2"
    ((args++))
}

while [[ -n $1 ]]; do
    args=1
    case "$1" in
        -h | --help )
            exec man "$base_name"
            ;;
        -a | -d)
            requiredarg "$@"
            ;;
        -+ )
            echo "$base_name: invalid option -- '${1//-/}'" >&2
            echo "Try \`$base_name --help' for more information." >&2
            exit
            ;;
        *)
            other_opts="$other_opts $1"
            ;;
    esac
    shift "$args"
done

[ -z "$add_disk" ] && {
    echo "$base_name: error: you must give either -a or -d options." >&2
    echo "Try \`$base_name --help' for more information." >&2
    exit
}

exec guestfish --rw -i $add_disk tar-in $other_opts
        
        
Version-Release number of selected component (if applicable):
libguestfs-tools-c-1.29.33-1.fc22.x86_64
        
        
How reproducible:
100%
        
        
Steps to Reproduce:
# virt-tar-in
libguestfs: error: no libvirt domain called 'tar-in': Domain not found: no domain with matching name 'tar-in'

# virt-tar-in Fedora-20.raw
libguestfs: error: no libvirt domain called 'tar-in': Domain not found: no domain with matching name 'tar-in'

# virt-tar-in -c
guestfish: option requires an argument -- 'c'
Try `guestfish --help' for more information.


Actual results:
As above

Expected results:
# virt-tar-in
virt-tar-in: error: you must give either -a or -d options.
Try `virt-tar-in --help' for more information.

# virt-tar-in Fedora-20.raw
virt-tar-in: error: you must give either -a or -d options.
Try `virt-tar-in --help' for more information.
        
# virt-tar-in -c
virt-tar-in: error: you must give either -a or -d options.
Try `virt-tar-in --help' for more information.


Additional info:

Comment 1 Richard W.M. Jones 2015-04-20 11:39:21 UTC
Although this is better than what we've got right now, this:

>         *)
>             other_opts="$other_opts $1"

doesn't quote the parameter correctly.  For example it would fail
if passed:

  virt-tar-in -a foo.img "Some File With A Space.tar" /bar

The way around that is to use bash arrays ... bleahhh.

Probably best to post a patch to the mailing list.

Comment 2 Lingfei Kong 2015-04-20 14:14:09 UTC
(In reply to Richard W.M. Jones from comment #1)
> Although this is better than what we've got right now, this:
> 
> >         *)
> >             other_opts="$other_opts $1"
> 
> doesn't quote the parameter correctly.  For example it would fail
> if passed:
> 
>   virt-tar-in -a foo.img "Some File With A Space.tar" /bar
> 
> The way around that is to use bash arrays ... bleahhh.
> 
> Probably best to post a patch to the mailing list.

Sorry, i missed this situation, possible i will post a patch if the code is ready to use. 

Thanks!

Comment 4 Fedora End Of Life 2016-07-19 20:53:03 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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