[libvirt] [PATCH] virsh: fix output the incorrect error after try failed

https://bugzilla.redhat.com/show_bug.cgi?id=1254152 When we use some virsh cmd which need specify domain name/id/uuid, if the command get failure we will get error like this: # virsh domif-setlink 123 vnet1 up error: interface (target: vnet1) not found error: Domain not found: no domain with matching id 123 The second line should be reset after call virshLookupDomainInternal, because after some tries we get domain pointer, so output error during we tried will make user confuse. Signed-off-by: Luyao Huang <lhuang@redhat.com> --- tools/virsh-domain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 173bb15..69c5562 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -98,6 +98,8 @@ virshLookupDomainInternal(vshControl *ctl, dom = virDomainLookupByName(priv->conn, name); } + vshResetLibvirtError(); + if (!dom) vshError(ctl, _("failed to get domain '%s'"), name); -- 1.8.3.1

On 17/08/15 11:56, Luyao Huang wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1254152
When we use some virsh cmd which need specify domain name/id/uuid, if the command get failure we will get error like this:
# virsh domif-setlink 123 vnet1 up error: interface (target: vnet1) not found error: Domain not found: no domain with matching id 123
The second line should be reset after call virshLookupDomainInternal, because after some tries we get domain pointer, so output error during we tried will make user confuse.
Signed-off-by: Luyao Huang <lhuang@redhat.com> --- tools/virsh-domain.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 173bb15..69c5562 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -98,6 +98,8 @@ virshLookupDomainInternal(vshControl *ctl, dom = virDomainLookupByName(priv->conn, name); }
+ vshResetLibvirtError(); + if (!dom) vshError(ctl, _("failed to get domain '%s'"), name);
ACK, I reworded the commit message and pushed. Erik

On 08/18/2015 08:56 PM, Erik Skultety wrote:
On 17/08/15 11:56, Luyao Huang wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1254152
When we use some virsh cmd which need specify domain name/id/uuid, if the command get failure we will get error like this:
# virsh domif-setlink 123 vnet1 up error: interface (target: vnet1) not found error: Domain not found: no domain with matching id 123
The second line should be reset after call virshLookupDomainInternal, because after some tries we get domain pointer, so output error during we tried will make user confuse.
Signed-off-by: Luyao Huang <lhuang@redhat.com> --- tools/virsh-domain.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 173bb15..69c5562 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -98,6 +98,8 @@ virshLookupDomainInternal(vshControl *ctl, dom = virDomainLookupByName(priv->conn, name); }
+ vshResetLibvirtError(); + if (!dom) vshError(ctl, _("failed to get domain '%s'"), name);
ACK, I reworded the commit message and pushed.
Thanks a lot for your quick review and help.
Erik
Luyao
participants (3)
-
Erik Skultety
-
lhuang
-
Luyao Huang