Bug 1254152 - error should be improved when use some virsh command get failure
error should be improved when use some virsh command get failure
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.2
x86_64 Linux
low Severity low
: rc
: ---
Assigned To: Libvirt Maintainers
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-17 05:49 EDT by Luyao Huang
Modified: 2016-11-03 14:22 EDT (History)
5 users (show)

See Also:
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 14:22:56 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Luyao Huang 2015-08-17 05:49:26 EDT
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 05:58:02 EDT
Send a patch to list:

https://www.redhat.com/archives/libvir-list/2015-August/msg00639.html
Comment 2 Erik Skultety 2015-08-18 08:58:44 EDT
fixed upstream:

commit 70f56dd72cdca309005c8234a8945721badbcfff
Author: Luyao Huang <lhuang@redhat.com>
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 01:40:19 EST
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 01:44:22 EST
Comment 4 is verified on libvirt-1.3.1-1.el7.x86_64.
Comment 7 errata-xmlrpc 2016-11-03 14:22:56 EDT
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

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