[libvirt] [PATCH 2/7] Report error if virMutexInit fails

Martin Kletzander mkletzan at redhat.com
Fri Jul 28 14:23:42 UTC 2017


On Thu, Jul 27, 2017 at 01:47:22PM +0200, Michal Privoznik wrote:
>The virMutexInit() function is not reporting any error on failure
>rather than returning -1 and setting errno. It's up to the caller
>to report the error.
>

I would rather see virMutexInit() report the error since it looks like
some code already counts on it (I haven't done any comparison) and
different error messages for each mutex does not really help anything
IMHO since mutex initialization is fatal anyway.

I think virthread.c does not report errors because we had multiple
implementations for it, but that's no longer true since 404174cad321
(late 2012).

>diff --git a/tools/virsh-console.c b/tools/virsh-console.c
>index c1927c28a..ab3339ec7 100644
>--- a/tools/virsh-console.c
>+++ b/tools/virsh-console.c
>@@ -351,8 +351,10 @@ virshRunConsole(vshControl *ctl,
>     if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0)
>         goto cleanup;
>
>-    if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0)
>+    if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0) {
>+        VIR_ERROR(_("unable to init console lock or condition"));

I don't see a reason for VIR_ERROR here.  Also virCondInit() and other
could report error, although that's not the aim of this patch.

>         goto cleanup;
>+    }
>
>     virMutexLock(&con->lock);
>
>--
>2.13.0
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170728/96ed6733/attachment-0001.sig>


More information about the libvir-list mailing list