From nobody Mon Feb 9 03:14:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641304071; cv=none; d=zohomail.com; s=zohoarc; b=G7XzE/YXWHF3EBcEbYcPu4+7wN/VMZflLxHrCCj6YItpNLqLPR9I29fs5AkFcalKOmgzEJuWSRKqTYdEVUxPJnNqqt+W0PQy8o/GRyBxUEP4k+zmxKMvgO4o+wpBKhHbEfwnkCH9T0mG7kH5Pewqw19rnFLmzRpMXSObvDqsWfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641304071; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UWbIjWKh82G8h2JQ2jjk7ttZifQatU/QPmWwGiAGOFA=; b=ZAJCovkA3Ffan90pVKNzZXSFsVJ/dct6gxmL/NEi88VH3dN8VH6lMusP0eDVY+uYfDTyNpUmU+elD3EphA/sx4syXxkgPqdGh7pb51kOZVkdkWBUDWFpVw/BdeYoqay3zTUKCRSu47SX81toyMZ+fTdmrBwjSgsDIELg/zfOspk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1641304071276767.0094841953843; Tue, 4 Jan 2022 05:47:51 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-jzHtzQmXPeqLZVuDoGti3g-1; Tue, 04 Jan 2022 08:47:48 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A65C1932481; Tue, 4 Jan 2022 13:47:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33C878795A; Tue, 4 Jan 2022 13:47:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 01850180BAAE; Tue, 4 Jan 2022 13:47:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 204DlOfg019625 for ; Tue, 4 Jan 2022 08:47:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 678C4112132E; Tue, 4 Jan 2022 13:47:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6335A1121324 for ; Tue, 4 Jan 2022 13:47:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4BBE428EC109 for ; Tue, 4 Jan 2022 13:47:24 +0000 (UTC) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-SvLXi-X9NlO0mh5hUpHl_Q-1; Tue, 04 Jan 2022 08:47:20 -0500 Received: by mail-wm1-f71.google.com with SMTP id m9-20020a05600c4f4900b0034644da3525so317963wmq.3 for ; Tue, 04 Jan 2022 05:47:20 -0800 (PST) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id i8sm38409640wmq.4.2022.01.04.05.47.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 05:47:18 -0800 (PST) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 7C5EC2FEE743 for ; Tue, 4 Jan 2022 14:47:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641304070; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UWbIjWKh82G8h2JQ2jjk7ttZifQatU/QPmWwGiAGOFA=; b=IivYhrjD5GuN6PPzUOryeADM0XNL7v/TEY5wW2Qo/DnFyRYP2mPzwa5XGkC2NJ7z2ZX+KP ApGVPwAWpscHAD0wcSKCqd6ToA0E9H70HEdTc/opksXqc+FgMXJ5gG7PY0qaIhtpjSW/vQ ZoikfPOdBTjaJG/5dAZ5IcrJG53eKSM= X-MC-Unique: jzHtzQmXPeqLZVuDoGti3g-1 X-MC-Unique: SvLXi-X9NlO0mh5hUpHl_Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UWbIjWKh82G8h2JQ2jjk7ttZifQatU/QPmWwGiAGOFA=; b=Q2vbA4K/Il4QrWqgAy3LipxYJpohmRvf+pybK0ujN5nogNSa4t0mGITrx8p7wVveFI dyKCQQtUVj2LsOcbaNR+WhFK4vNiKFbdNMtXzR1V2TXPu6bh/DZ76fGlfGIzTcGQth4X Byg0mPjIAVVzDdQF5M592Z5FI5aqSfmFW9wav6SWBNXk07g1o2lZS4jrH7j57P/1UtwL oB/wAAcPFeR393axQzlk3mZqHL+kG9x+nBolCQZrVVy9fnoMYPhVK/GxBqvya02d2udO T2xms5FCwGdIzsGKWFgGEx5T5gG+N//vF1+wVFruQ5/l/TXPysE+TpV8zrl7ntqaEgFd 3KKQ== X-Gm-Message-State: AOAM533LlhU/ZqhjdIi+pgFDfVEAIe7KTqbVDuev9kMENVqrkd5ovWO4 F7KB701jCpo3M9rIhFkcCAfRbUOcTqy551aNrmU4Jo8K+KcloxPMeP59ZGqUH05q41wCL3Sifzy 8OODrqVaxpJiqSdvV5AsjHm4DOpQHrkMWbkrOMzo5+j19LLCKhO0SB9hdII2b8yZZYAc4REk= X-Received: by 2002:adf:de03:: with SMTP id b3mr15803026wrm.448.1641304039411; Tue, 04 Jan 2022 05:47:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8dnu8Kb5RzWuZd+S5++ii8wuHzSb1SDCGVP2SIHjar+xRPasb/NcWxKKBPkyojZznJ19lpQ== X-Received: by 2002:adf:de03:: with SMTP id b3mr15803009wrm.448.1641304039144; Tue, 04 Jan 2022 05:47:19 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 7/8] Dispatch error in virInitialize Date: Tue, 4 Jan 2022 14:47:11 +0100 Message-Id: <77d81d691af1c67f8d54c20219ba1488e7cba719.1641303832.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641304073560100005 Content-Type: text/plain; charset="utf-8" Callers that already do this anyway can be cleaned up thanks to this and th= e one that does not (daemon startup) gains the benefit of the error being printed= to standard error output changing: LIBVIRT_LOG_OUTPUTS=3D1:invalid libvirtd /home/nert/dev/libvirt/upstream/build/src/libvirtd: initialisation failed into: LIBVIRT_LOG_OUTPUTS=3D1:invalid libvirtd libvirt: error : invalid argument: Invalid destination 'invalid' for outpu= t '1:invalid' /home/nert/dev/libvirt/upstream/build/src/libvirtd: initialisation failed Signed-off-by: Martin Kletzander Reviewed-by: Erik Skultety --- src/libvirt.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 35fd74fe08da..45315f484c97 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -309,11 +309,12 @@ virGlobalInit(void) int virInitialize(void) { - if (virOnce(&virGlobalOnce, virGlobalInit) < 0) + if (virOnce(&virGlobalOnce, virGlobalInit) < 0 || + virGlobalError) { + virDispatchError(NULL); return -1; + } =20 - if (virGlobalError) - return -1; return 0; } =20 @@ -1200,18 +1201,15 @@ virConnectOpen(const char *name) virConnectPtr ret =3D NULL; =20 if (virInitialize() < 0) - goto error; + return NULL; =20 VIR_DEBUG("name=3D%s", NULLSTR(name)); virResetLastError(); ret =3D virConnectOpenInternal(name, NULL, 0); if (!ret) - goto error; - return ret; + virDispatchError(NULL); =20 - error: - virDispatchError(NULL); - return NULL; + return ret; } =20 =20 @@ -1236,18 +1234,14 @@ virConnectOpenReadOnly(const char *name) virConnectPtr ret =3D NULL; =20 if (virInitialize() < 0) - goto error; + return NULL; =20 VIR_DEBUG("name=3D%s", NULLSTR(name)); virResetLastError(); ret =3D virConnectOpenInternal(name, NULL, VIR_CONNECT_RO); if (!ret) - goto error; + virDispatchError(NULL); return ret; - - error: - virDispatchError(NULL); - return NULL; } =20 =20 @@ -1276,18 +1270,14 @@ virConnectOpenAuth(const char *name, virConnectPtr ret =3D NULL; =20 if (virInitialize() < 0) - goto error; + return NULL; =20 VIR_DEBUG("name=3D%s, auth=3D%p, flags=3D0x%x", NULLSTR(name), auth, f= lags); virResetLastError(); ret =3D virConnectOpenInternal(name, auth, flags); if (!ret) - goto error; + virDispatchError(NULL); return ret; - - error: - virDispatchError(NULL); - return NULL; } =20 =20 --=20 2.34.1