Bug 1281707

Summary: some virsh cmd get failure without set error message
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, jtomko, mzhan, rbalakri, yalzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:30:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luyao Huang 2015-11-13 08:23:06 UTC
Description of problem:
some virsh cmd get failure without set error message 

Version-Release number of selected component (if applicable):
libvirt-1.2.17-13.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.

# virsh blockcopy RHEL71-lhuang --dest '' --path vda

# echo $?
1

2.

# virsh event RHEL71-lhuang --event ''

# echo $?
1


3.

# virsh net-event default --event ''

# echo $?
1

4.

# virsh net-dhcp-leases default --mac ''


# echo $?
1

5.

# virsh domifaddr RHEL71-lhuang --interface ''

# echo $?
1


Actual results:

some virsh cmd get failure without set error message 

Expected results:

error like "invalid strings"

Additional info:

Comment 1 Jaroslav Suchanek 2015-11-26 12:53:11 UTC
*** Bug 1261432 has been marked as a duplicate of this bug. ***

Comment 2 Ján Tomko 2015-12-03 13:06:35 UTC
Upstream patches:
https://www.redhat.com/archives/libvir-list/2015-December/msg00100.html

Comment 3 Ján Tomko 2015-12-04 11:19:47 UTC
Pushed as:
commit 45138725cf2a14575aa5204fe55efd6668b9b03a
Author:     Ján Tomko <jtomko>
CommitDate: 2015-12-03 13:58:52 +0100

    virsh: report errors for empty strings
    
    Several callers were using vshCommandOptString without setting an error.
    Use vshCommandOptStringReq which sets the error.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1281707

git describe: v1.3.0-rc1-4-g4513872

Comment 5 yalzhang@redhat.com 2016-02-26 10:25:09 UTC
Verified on libvirt-1.3.1-1.el7.x86_64, the results as expected. All the command on the bug will get a fail information.

1.
[root@work images]# virsh blockcopy test --dest /var/lib/libvirt/images/bak vda
Block Copy started

[root@work images]# virsh blockcopy test --dest ' ' vda
Block Copy started

[root@work images]# virsh blockcopy test --dest '' vda
error: Failed to get option 'dest': Option argument is empty

[root@work images]# virsh blockcopy test --dest /var/lib/libvirt/images/bbk --path ''
error: Failed to get option 'path': Option argument is empty

[root@work images]# virsh blockcopy test --dest /var/lib/libvirt/images/bbk
error: command 'blockcopy' requires <path> option

[root@work images]# virsh blockcopy test vda
error: need either --dest or --xml

2.
[root@work Desktop]# virsh event rhel7.2 --event ''
error: Failed to get option 'event': Option argument is empty

[root@work Desktop]# virsh event rhel7.2 --event 'ss'
error: unknown event type ss

[root@work Desktop]# virsh event rhel7.2 --event "lifecycle"
event 'lifecycle' for domain rhel7.2: Resumed Unpaused
events received: 1

[root@work Desktop]# virsh event rhel7.2 --event
error: expected syntax: --event <string>

3.
[root@work images]# virsh net-event default --event ''
error: Failed to get option 'event': Option argument is empty

[root@work images]# virsh net-event default --event ' '
error: unknown event type

[root@work images]# virsh net-event default --event ss
error: unknown event type ss

4. see bug 1261432
[root@work images]# virsh net-dhcp-leases default --mac ''
error: Failed to get option 'mac': Option argument is empty

[root@work images]# virsh net-dhcp-leases default --mac ' '
error: Failed to get leases info for default
error: invalid MAC address:  

[root@work images]# virsh net-dhcp-leases default --mac 99
error: Failed to get leases info for default
error: invalid MAC address: 99

5.
[root@test /]# virsh domifaddr rhel7.2 ''
error: Failed to get option 'interface': Option argument is empty
[root@test /]# virsh domifaddr rhel7.2
Name MAC address Protocol Address
-------------------------------------------------------------------------------
vnet0 52:54:00:1b:6f:e5 ipv4 192.168.122.159/24

[root@test /]# virsh domifaddr rhel7.2 vnet1
Name MAC address Protocol Address
-------------------------------------------------------------------------------

[root@test /]# virsh destroy rhel7.2
Domain rhel7.2 destroyed
[root@test /]# virsh domifaddr rhel7.2
error: Failed to query for interfaces addresses
error: Requested operation is not valid: domain is not running

Modify the bug status to verified.

Comment 7 errata-xmlrpc 2016-11-03 18:30:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2577.html