Bug 1254152

Summary: error should be improved when use some virsh command get failure
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, eskultet, 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:22:56 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-08-17 09:49:26 UTC
Description of problem:
the error should be improved when use some virsh command get failure

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

How reproducible:
100%

Steps to Reproduce:
1.prepare a guest which use a name which is number:

# virsh list
 Id    Name                           State
----------------------------------------------------
 2     123                            running


2. chose a command which need pass guest name:

# virsh domiflist 123
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    rtl8139     52:54:00:59:d5:b8

# virsh domif-setlink 123 vnet1 up
error: interface (target: vnet1) not found
error: Domain not found: no domain with matching id 123


3.

Actual results:

virsh output an extra error "error: Domain not found: no domain with matching id 123"


Expected results:

# virsh domif-setlink 123 vnet1 up
error: interface (target: vnet1) not found

we should not output this error, since it is just a try of virsh function virsh/vshLookupDomainInternal, and we get the correct guest pointer after try id,uuid,name, so this error should be reset after these tries.

Additional info:

Comment 1 Luyao Huang 2015-08-17 09:58:02 UTC
Send a patch to list:

https://www.redhat.com/archives/libvir-list/2015-August/msg00639.html

Comment 2 Erik Skultety 2015-08-18 12:58:44 UTC
fixed upstream:

commit 70f56dd72cdca309005c8234a8945721badbcfff
Author: Luyao Huang <lhuang>
Date:   Mon Aug 17 17:56:48 2015 +0800

    virsh: Reset global error after successfull domain lookup
    
    When looking up a domain, we try to look up by ID, UUID and NAME
    consequently while not really caring which of those lookups succeeds.
    The problem is that if any of them fails, we dispatch the error from the
    driver and that means setting both threadlocal and global error. Let's
    say the last lookup (by NAME) succeeds and resets the threadlocal error as any
    other API does, however leaving the global error unchanged. If the underlying
    virsh command does not succeed afterwards, our cleanup routine in
    vshCommandRun ensures that no libvirt error will be forgotten and that's
    exactly where this global error comes in incorrectly.
    
     # virsh domif-setlink 123 vnet1 up
     error: interface (target: vnet1) not found
     error: Domain not found: no domain with matching id 123
    
    This patch also resets the global error which would otherwise cause some
    minor confusion in reported error messages.

v1.2.18-135-g70f56dd

Comment 4 yalzhang@redhat.com 2016-03-01 06:40:19 UTC
Verified as below, the error message is excepted.Modify the bug to verified.

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 16    123                            running

# virsh domiflist 123
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    rtl8139     52:54:00:bb:25:71

# virsh domiflist 1234
error: failed to get domain '1234'
error: Domain not found: no domain with matching name '1234'

# virsh domif-setlink 123 vnet1 up
error: interface (target: vnet1) not found

# virsh domif-setlink 16 vnet1 up
error: interface (target: vnet1) not found

# virsh domifstat 123 vnet1
error: Failed to get interface stats 123 vnet1
error: invalid argument: invalid path, 'vnet1' is not a known interface

# virsh domiftune 123 vnet5
error: Unable to get interface parameters
error: invalid argument: Can't find device vnet5

Comment 5 yalzhang@redhat.com 2016-03-01 06:44:22 UTC
Comment 4 is verified on libvirt-1.3.1-1.el7.x86_64.

Comment 7 errata-xmlrpc 2016-11-03 18:22:56 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