]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Reset global error after successfull domain lookup
authorLuyao Huang <lhuang@redhat.com>
Mon, 17 Aug 2015 09:56:48 +0000 (17:56 +0800)
committerErik Skultety <eskultet@redhat.com>
Tue, 18 Aug 2015 12:54:45 +0000 (14:54 +0200)
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.

https://bugzilla.redhat.com/show_bug.cgi?id=1254152

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
tools/virsh-domain.c

index 437e43e6c3e5a69170832f112fdcab0691e4c5a1..8d2700f56182d887c9c48d86dd24fa55b523d682 100644 (file)
@@ -98,6 +98,8 @@ virshLookupDomainInternal(vshControl *ctl,
         dom = virDomainLookupByName(priv->conn, name);
     }
 
+    vshResetLibvirtError();
+
     if (!dom)
         vshError(ctl, _("failed to get domain '%s'"), name);