From nobody Wed Apr 15 07:03:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775621491; cv=none; d=zohomail.com; s=zohoarc; b=NKyByUvRFG2SzEMggukbcZt4f0c4XOnFMPgWYMbJsg0Nprhe7RcEKPK57TBThRf/7cih0BFLXP1obh46R0D/jmLhuKivhhkxU6EQwNu6X3FeqdevfX//tAw58XLO8AtAM2qET1q8+FYRlLIt5LCijxHw88xoBaY1IsXT7X9pPUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775621491; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=MJRIBnvJFOyKJn2SswufqU+BP6tbvdIzlhRgPprOIfc=; b=ai/tob/+aGub91/RjKXZIZmoOPUfCLt6Wmqvx8YNJZDnpqQOlNSgrpXNXv2Jh2DmzEHV8RD3B4KTg6H6dVbSwh7NRFhDUW8tgXqW7N5rPpuL9yE9o5R49JtAfIH0PPOYKSzizGvV003TSChMUH1Dh0IITEUa+pea/Yr9WVqQX8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1775621491475591.7241804509048; Tue, 7 Apr 2026 21:11:31 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B63F13F956; Wed, 8 Apr 2026 00:11:29 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 0EAF64187D; Wed, 8 Apr 2026 00:10:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1DC1D3F8B4; Wed, 8 Apr 2026 00:10:46 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7EE6C3F362 for ; Wed, 8 Apr 2026 00:10:43 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-p2qfTMy_Mv6VOWG2fpnvGA-1; Wed, 08 Apr 2026 00:10:41 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6FFD195608D for ; Wed, 8 Apr 2026 04:10:40 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5533B300019F for ; Wed, 8 Apr 2026 04:10:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775621443; h=from:from: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; bh=MJRIBnvJFOyKJn2SswufqU+BP6tbvdIzlhRgPprOIfc=; b=FI+CzfceufeyTRwcrJzWZhjVv9alt3E7PZWW+AqHqDFbpnhUlexfndPNfqct5g4GiabdVo IFvzljO2j4i4fte6dbo0kJsvfRc6j4QBIfTcpUTo+xwYOSfL6BklPqvrayLXBbMxDmuqWX flb33ap7C/XU9yUPf9xpmVPNiS42/xw= X-MC-Unique: p2qfTMy_Mv6VOWG2fpnvGA-1 X-Mimecast-MFC-AGG-ID: p2qfTMy_Mv6VOWG2fpnvGA_1775621440 To: devel@lists.libvirt.org Subject: [PATCH v2 1/6] util: log the name of the log directory that couldn't be created Date: Wed, 8 Apr 2026 00:10:33 -0400 Message-ID: <20260408041038.424650-2-laine@redhat.com> In-Reply-To: <20260408041038.424650-1-laine@redhat.com> References: <20260408041038.424650-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: fBSph4nbz2QP7PuJYpb9zddHqTRbkcOHJ3velS7hamI_1775621440 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KEAR4KJFGIUFPINFUHET355NP6HSGCCR X-Message-ID-Hash: KEAR4KJFGIUFPINFUHET355NP6HSGCCR X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775621493290158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump The message previously just said "Could not create log directory", but didn't provide the name of the directory, which could be helpful in determine why the failure occured. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index c24dfa83c4..9f53c72975 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -178,7 +178,7 @@ virLogSetDefaultOutputToFile(const char *binary, bool p= rivileged) old_umask =3D umask(077); if (g_mkdir_with_parents(logdir, 0777) < 0) { umask(old_umask); - virReportSystemError(errno, "%s", _("Could not create log dire= ctory")); + virReportSystemError(errno, _("Could not create log directory = '%1$s'"), logdir); return -1; } umask(old_umask); --=20 2.53.0 From nobody Wed Apr 15 07:03:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775621541; cv=none; d=zohomail.com; s=zohoarc; b=RPktTL/M/SlqzyK4akIpFoDcN8CyxU4HBPPhG1XLLHOYA7QDW/u/IicPz2GzjMPu4oeXpxtn8QxtjCO909rpy/zD8cwaefaSg7r3CRIaOSrhP930eqOp/9XE7tSFi2OlB7LkYviZDVvK+22GTNMbYF7VfMCw71BkPSe2D52HGcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775621541; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=l+nTiomHXRUcaqspjFDItcDTcI2MFgCxseLy/DCYyoU=; b=RyiILvBnTKSCLhCVaekaBEBlNAeQSFNmtJ2+B0HMUzh6uBugFPRgfzRoaen2JSAGuR+SljjdWgo0jgemOSdg4zK9ojc1XTLELgoErVyWu2a3FuKDY3U5eEzv1MPozz4BfmBWJVa/+sjWMrHH2pMf1pMDRu3y57uAlPZMm+tf1vY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1775621541830802.1541644393373; Tue, 7 Apr 2026 21:12:21 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1B42E417D6; Wed, 8 Apr 2026 00:12:21 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 9BD69418FE; Wed, 8 Apr 2026 00:10:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 8F4873F8E4; Wed, 8 Apr 2026 00:10:46 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 24F663F83B for ; Wed, 8 Apr 2026 00:10:44 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-590-ydO_SJPEMHGgdXWcVzc05Q-1; Wed, 08 Apr 2026 00:10:42 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4ABC4195608C for ; Wed, 8 Apr 2026 04:10:41 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E6889300019F for ; Wed, 8 Apr 2026 04:10:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775621443; h=from:from: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; bh=l+nTiomHXRUcaqspjFDItcDTcI2MFgCxseLy/DCYyoU=; b=jVTdAlcquvX131FRmSSa8ILUpEQkXqtkDFVUh1A/uAj9z5KStaZhuxORXj30LPavw6PIkY cJNq3lvinFDAPBydC4RfLAlt+n7MsNSUzbnrmi0+rjG/7wuC4CdsbY21zNBOFWO6hKzkH6 BL7CUtIrCK7jsCfT8Qk6qOL2ivivHpI= X-MC-Unique: ydO_SJPEMHGgdXWcVzc05Q-1 X-Mimecast-MFC-AGG-ID: ydO_SJPEMHGgdXWcVzc05Q_1775621441 To: devel@lists.libvirt.org Subject: [PATCH v2 2/6] util: consistently use typedef virLogMetadata Date: Wed, 8 Apr 2026 00:10:34 -0400 Message-ID: <20260408041038.424650-3-laine@redhat.com> In-Reply-To: <20260408041038.424650-1-laine@redhat.com> References: <20260408041038.424650-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: STIorn1kmo5xf_AIF9C8JcTVnFY57UTHoh0qGNQXdUE_1775621441 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WBRYQEUJ3AC6MUW3GMI5E3UT24CNNKES X-Message-ID-Hash: WBRYQEUJ3AC6MUW3GMI5E3UT24CNNKES X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775621548593154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump For some reason there were some uses of this struct where "struct _virLogMetadata" was used instead of just using the typedef "virLogMetadata" (they are both defined in the same file - virlog.h). Possibly at one point the struct was in virlog.c and outsiders could only see it as an opaque object, but even if that was the case, there are already cases of the typedef being used outside of virlog.c, and constinuing to use "struct _virLogMetadata" in some places both looks too much K&R 1st edition and might incorrectly imply to someone that there *is* data abstraction/hiding going on when there really isn't. So let's just always use plain virLogMetadata. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/util/virlog.c | 12 ++++++------ src/util/virlog.h | 4 ++-- tests/testutils.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 9f53c72975..30cb68fe7d 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -116,7 +116,7 @@ static void virLogOutputToFd(virLogSource *src, int linenr, const char *funcname, const char *timestamp, - struct _virLogMetadata *metadata, + virLogMetadata *metadata, const char *rawstr, const char *str, void *data); @@ -500,7 +500,7 @@ virLogVMessage(virLogSource *source, const char *filename, int linenr, const char *funcname, - struct _virLogMetadata *metadata, + virLogMetadata *metadata, const char *fmt, va_list vargs) { @@ -627,7 +627,7 @@ virLogMessage(virLogSource *source, const char *filename, int linenr, const char *funcname, - struct _virLogMetadata *metadata, + virLogMetadata *metadata, const char *fmt, ...) { va_list ap; @@ -646,7 +646,7 @@ virLogOutputToFd(virLogSource *source G_GNUC_UNUSED, int linenr G_GNUC_UNUSED, const char *funcname G_GNUC_UNUSED, const char *timestamp, - struct _virLogMetadata *metadata G_GNUC_UNUSED, + virLogMetadata *metadata G_GNUC_UNUSED, const char *rawstr G_GNUC_UNUSED, const char *str, void *data) @@ -746,7 +746,7 @@ virLogOutputToSyslog(virLogSource *source G_GNUC_UNUSED, int linenr G_GNUC_UNUSED, const char *funcname G_GNUC_UNUSED, const char *timestamp G_GNUC_UNUSED, - struct _virLogMetadata *metadata G_GNUC_UNUSED, + virLogMetadata *metadata G_GNUC_UNUSED, const char *rawstr G_GNUC_UNUSED, const char *str, void *data G_GNUC_UNUSED) @@ -890,7 +890,7 @@ virLogOutputToJournald(virLogSource *source, int linenr, const char *funcname, const char *timestamp G_GNUC_UNUSED, - struct _virLogMetadata *metadata, + virLogMetadata *metadata, const char *rawstr, const char *str G_GNUC_UNUSED, void *data) diff --git a/src/util/virlog.h b/src/util/virlog.h index 4f755c543b..77ba40b2e4 100644 --- a/src/util/virlog.h +++ b/src/util/virlog.h @@ -127,7 +127,7 @@ typedef void (*virLogOutputFunc) (virLogSource *src, int linenr, const char *funcname, const char *timestamp, - struct _virLogMetadata *metadata, + virLogMetadata *metadata, const char *rawstr, const char *str, void *data); @@ -170,7 +170,7 @@ void virLogMessage(virLogSource *source, const char *filename, int linenr, const char *funcname, - struct _virLogMetadata *metadata, + virLogMetadata *metadata, const char *fmt, ...) G_GNUC_PRINTF(7, 8); =20 bool virLogProbablyLogMessage(const char *str); diff --git a/tests/testutils.c b/tests/testutils.c index 14e5c56fcf..35571fb2ad 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -680,7 +680,7 @@ virtTestLogOutput(virLogSource *source G_GNUC_UNUSED, int lineno G_GNUC_UNUSED, const char *funcname G_GNUC_UNUSED, const char *timestamp, - struct _virLogMetadata *metadata G_GNUC_UNUSED, + virLogMetadata *metadata G_GNUC_UNUSED, const char *rawstr G_GNUC_UNUSED, const char *str, void *data) --=20 2.53.0 From nobody Wed Apr 15 07:03:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775621742; cv=none; d=zohomail.com; s=zohoarc; b=HPDFgB8SOfJCFORVVEeZHV/PkbgbFF5+ltXya3Nivlis3DcUVOwUsyKd1h5/Gh+FRzjfRgwXbdrmmA9HviKCd7U/4+YUaRMeUTG3cQcwF4Lc7b/+n/uG+QcLgk+HdhVkTxH04Mqk3pddd8aaRJz0hAHyuaQjAwjPfqJt9WcAYOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775621742; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=/fdGYi5sYboTjjx95Rs4HUwhEk3/sz2YMpgphCZAxF4=; b=Q8rTnIORJURTFxJYxA5cDp+RXioPCix714cKfixMzJG/Hn/tykwTZonWBoOZ8wOpg2LZBdUd0rTmJ4bGwMW9nUAzuOjJftf+m4qU5COHlPiucgzKpWr2jgZ56q6qY2wsUCSc+ZWZRM2Rbt7l+K0GusTPwlwYWiHyNglOnhJPx/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1775621742353408.4840240007145; Tue, 7 Apr 2026 21:15:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9FF073F35B; Wed, 8 Apr 2026 00:15:41 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id D2D9F41B4A; Wed, 8 Apr 2026 00:11:31 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A01B03F935; Wed, 8 Apr 2026 00:11:27 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E8C8B41892 for ; Wed, 8 Apr 2026 00:10:50 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-DPR8BD_0MNuohddhD3kO2A-1; Wed, 08 Apr 2026 00:10:42 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D437A1956094 for ; Wed, 8 Apr 2026 04:10:41 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7BCF2300019F for ; Wed, 8 Apr 2026 04:10:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775621450; h=from:from: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; bh=/fdGYi5sYboTjjx95Rs4HUwhEk3/sz2YMpgphCZAxF4=; b=bcvfaYnEw/3t6ptrVmSjWcR6t0hWwe3QIinMSKQBMuF62/XnJNfcSzp/9sb95tDOt/zpbO i2bmEMMw2bPvHNEh5r1kOrMbujB/apMV1VklH0NUOz4CI47BgqvHnE1UYi8KxE3TmCc7JV uOdmX/i2LnkxhKmjw8t2aQ01fMGPzP4= X-MC-Unique: DPR8BD_0MNuohddhD3kO2A-1 X-Mimecast-MFC-AGG-ID: DPR8BD_0MNuohddhD3kO2A_1775621442 To: devel@lists.libvirt.org Subject: [PATCH v2 3/6] util: eliminate duplicate code in virLogVMessage Date: Wed, 8 Apr 2026 00:10:35 -0400 Message-ID: <20260408041038.424650-4-laine@redhat.com> In-Reply-To: <20260408041038.424650-1-laine@redhat.com> References: <20260408041038.424650-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: l5vPNcrzrNcsFOWbAehBrnJluSTqTN-QX0-qoE4b2FI_1775621442 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 65ZEP3ZGYLJDJBVGDKUGIMHNJUST7VTD X-Message-ID-Hash: 65ZEP3ZGYLJDJBVGDKUGIMHNJUST7VTD X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775621745169154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump The same several lines were repeated, once in a loop iterating through all log targets, and again to output to stderr when there are no log targets specified. This just moves those lines into a helper function, making it easier and less error prone to add additional info to the banner that is logged each time a daemon starts logging. Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- src/util/virlog.c | 127 ++++++++++++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 30cb68fe7d..8d0d926d58 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -479,6 +479,75 @@ virLogSourceUpdate(virLogSource *source) } =20 =20 +/** + * virLogToOneTarget: + * + * (these first several args are coming directly from the args of + * virLogVMessage() - you can find their description there) + * + * @source, @priority, @filename, @linenr, @funcname, @metadata: + * + * (the next 3 are created once during each call to virLogMMessage() and r= eused + * for each target) + * + * @timestamp: cached (during this one log to multiple targets) raw time + * @str: the log message formatted from what appears in the VIR_*() + or virReport*() call + * @msg: the formatted log message with function name, line number= , and + * priority added + * + * @outputFunc: pointer to function to call to output the data + * @data: private data used by @outputFunc (e.g. fd to write to) + * @needInit: pointer to bool that gets set to false once the + * once-per-daemon-run init message has been sent to this ta= rget + * + * If needInit is true, construct the strings to send the "init" + * message (a banner with software version, etc) to the log target + * using @outputFunc and set @needInit to false. Then send the current + * log message to the target (described by the other args) using + * @outputFunc. + */ +static void +virLogToOneTarget(virLogSource *source, + virLogPriority priority, + const char *filename, + int linenr, + const char *funcname, + virLogMetadata *metadata, + const char *timestamp, + const char *str, + const char *msg, + virLogOutputFunc outputFunc, + void *data, + bool *needInit) +{ + if (*needInit) { + const char *rawinitmsg; + char *hoststr =3D NULL; + char *initmsg =3D NULL; + + virLogVersionString(&rawinitmsg, &initmsg); + outputFunc(&virLogSelf, VIR_LOG_INFO, + __FILE__, __LINE__, __func__, + timestamp, NULL, rawinitmsg, initmsg, + data); + VIR_FREE(initmsg); + + virLogHostnameString(&hoststr, &initmsg); + outputFunc(&virLogSelf, VIR_LOG_INFO, + __FILE__, __LINE__, __func__, + timestamp, NULL, hoststr, initmsg, + data); + VIR_FREE(hoststr); + VIR_FREE(initmsg); + *needInit =3D false; + } + + outputFunc(source, priority, filename, linenr, funcname, + timestamp, metadata, str, msg, data); +} + + /** * virLogVMessage: * @source: where is that message coming from @@ -548,57 +617,19 @@ virLogVMessage(virLogSource *source, */ for (i =3D 0; i < virLogNbOutputs; i++) { if (priority >=3D virLogOutputs[i]->priority) { - if (virLogOutputs[i]->logInitMessage) { - const char *rawinitmsg; - char *hoststr =3D NULL; - char *initmsg =3D NULL; - virLogVersionString(&rawinitmsg, &initmsg); - virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, rawinitmsg, initmsg, - virLogOutputs[i]->data); - VIR_FREE(initmsg); - - virLogHostnameString(&hoststr, &initmsg); - virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, hoststr, initmsg, - virLogOutputs[i]->data); - VIR_FREE(hoststr); - VIR_FREE(initmsg); - virLogOutputs[i]->logInitMessage =3D false; - } - virLogOutputs[i]->f(source, priority, - filename, linenr, funcname, - timestamp, metadata, - str, msg, virLogOutputs[i]->data); + virLogToOneTarget(source, priority, filename, linenr, funcname= , metadata, + timestamp, str, msg, + virLogOutputs[i]->f, + virLogOutputs[i]->data, + &virLogOutputs[i]->logInitMessage); } } if (virLogNbOutputs =3D=3D 0) { - if (logInitMessageStderr) { - const char *rawinitmsg; - char *hoststr =3D NULL; - char *initmsg =3D NULL; - virLogVersionString(&rawinitmsg, &initmsg); - virLogOutputToFd(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, rawinitmsg, initmsg, - (void *) STDERR_FILENO); - VIR_FREE(initmsg); - - virLogHostnameString(&hoststr, &initmsg); - virLogOutputToFd(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, hoststr, initmsg, - (void *) STDERR_FILENO); - VIR_FREE(hoststr); - VIR_FREE(initmsg); - logInitMessageStderr =3D false; - } - virLogOutputToFd(source, priority, - filename, linenr, funcname, - timestamp, metadata, - str, msg, (void *) STDERR_FILENO); + virLogToOneTarget(source, priority, filename, linenr, funcname, me= tadata, + timestamp, str, msg, + virLogOutputToFd, + (void *) STDERR_FILENO, + &logInitMessageStderr); } virLogUnlock(); =20 --=20 2.53.0 From nobody Wed Apr 15 07:03:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775621693; cv=none; d=zohomail.com; s=zohoarc; b=cOn5RSLgG/iO7KfCDEt2UUD/+FMX7yx516RmfmZeI0JuA7OoFLu5DE70p+06f6ZTjJqEY9hzWxZ66hAAKInSMI17HtMuGSqWpjHomX19iM9lIobYY0jujd7tqZIkljVQQl07zX/IWxAKVq5ktlbtFxPJdftS92dp+6458AQvCV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775621693; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=x6U7yKBrVVy9F1WCmZjcqoRCmiGudVkTjYyUm2/2swI=; b=Xo0sBskOt7H/I8X8yHiHnx5nDwpub8Wqt7NGdRaHYsW1dkQpOrZKIhTglPuJxpuXE86rBWt818Ij2VmmOce2eqzSm+nQkQT6Qp9R96kru3rqooCurGOn9ry2M4vVTsZxYyCV9xe2CNe1R511o5Srgo/n6mRCeHCpOv6IeJCIuwk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 177562169364098.42535340077609; Tue, 7 Apr 2026 21:14:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 58DB53F95A; Wed, 8 Apr 2026 00:14:52 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 0235C41AE1; Wed, 8 Apr 2026 00:10:58 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5F3A93F35B; Wed, 8 Apr 2026 00:10:47 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 164063F8B3 for ; Wed, 8 Apr 2026 00:10:45 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-wr1CEaQtOjylJClyJ1ceSQ-1; Wed, 08 Apr 2026 00:10:43 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6A65E1956096 for ; Wed, 8 Apr 2026 04:10:42 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1019930001BB for ; Wed, 8 Apr 2026 04:10:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775621444; h=from:from: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; bh=x6U7yKBrVVy9F1WCmZjcqoRCmiGudVkTjYyUm2/2swI=; b=dKyLG5/rwGD/Tef+iHrnXMWqfRoDnSBXRrTs/JfFM06CHJJqbHn+7ITzj29Vivg25PXzuO nLy8HFz4dF7O5cGUD4Xxm+2Vp8uvIWq/ZKDRB/XidQcMIF5vfOounBWGslcGLR4npohRix cmdRL1FnOcHDXai+5wjfJvDDKV3dizQ= X-MC-Unique: wr1CEaQtOjylJClyJ1ceSQ-1 X-Mimecast-MFC-AGG-ID: wr1CEaQtOjylJClyJ1ceSQ_1775621442 To: devel@lists.libvirt.org Subject: [PATCH v2 4/6] util: make it easier to add lines to the log "init banner" Date: Wed, 8 Apr 2026 00:10:36 -0400 Message-ID: <20260408041038.424650-5-laine@redhat.com> In-Reply-To: <20260408041038.424650-1-laine@redhat.com> References: <20260408041038.424650-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2KOvkW-W3_Z-B7ctY9wu1akUZl5b70f_k7QdPL_ob1A_1775621442 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FOUUOQLNXOQFQZQK2KFMBLV6KFMKZ6A2 X-Message-ID-Hash: FOUUOQLNXOQFQZQK2KFMBLV6KFMKZ6A2 X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775621694544154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump The same thing happens for each line of the log banner: 1) A helper function is called that a) creates a "raw" string (just the desired info, e.g. version string) and b) calls virLogFormatString() to create a "cooked" version of the string (containing thread-id and log priority) 2) the outputFunc for the target is called with strings (a) and (b) By making a helper that does (1b) & (2), we can further reduce the amount of redundant code that needs to be written to add another line to the banner - now all we need to do is: 1) create the raw string 2) call the helper, sending it the raw string Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- V2: fixed formatting of a function definition noticed by Peter src/util/virlog.c | 82 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 8d0d926d58..cab23f613f 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -433,30 +433,6 @@ virLogFormatString(char **msg, } =20 =20 -static void -virLogVersionString(const char **rawmsg, - char **msg) -{ - *rawmsg =3D VIR_LOG_VERSION_STRING; - virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, VIR_LOG_VERSION_STRING); -} - -/* Similar to virGetHostname() but avoids use of error - * reporting APIs or logging APIs, to prevent recursion - */ -static void -virLogHostnameString(char **rawmsg, - char **msg) -{ - char *hoststr; - - hoststr =3D g_strdup_printf("hostname: %s", g_get_host_name()); - - virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, hoststr); - *rawmsg =3D hoststr; -} - - static void virLogSourceUpdate(virLogSource *source) { @@ -479,6 +455,34 @@ virLogSourceUpdate(virLogSource *source) } =20 =20 +/** + * virLogOneInitMsg: + * + * @str: the "raw" form of the string that's going to be logged + * + * (the args are all described in the caller - virLogToOneTarget() + * @timestamp,@outputFunc, @data + * + * send one "init message" (the lines that are at the beginning of the + * log when a new daemon starts) to one target. This just creates the + * "fancy" version of the string with thread-id and priority, and + * sends that, along with the "raw" version of the string, to the log + * target at INFO level. + */ +static void +virLogOneInitMsg(const char *timestamp, + const char *str, + virLogOutputFunc outputFunc, + void *data) +{ + g_autofree char *msg =3D NULL; + + virLogFormatString(&msg, 0, NULL, VIR_LOG_INFO, str); + outputFunc(&virLogSelf, VIR_LOG_INFO, __FILE__, __LINE__, __func__, + timestamp, NULL, str, msg, data); +} + + /** * virLogToOneTarget: * @@ -522,24 +526,18 @@ virLogToOneTarget(virLogSource *source, bool *needInit) { if (*needInit) { - const char *rawinitmsg; - char *hoststr =3D NULL; - char *initmsg =3D NULL; - - virLogVersionString(&rawinitmsg, &initmsg); - outputFunc(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, rawinitmsg, initmsg, - data); - VIR_FREE(initmsg); - - virLogHostnameString(&hoststr, &initmsg); - outputFunc(&virLogSelf, VIR_LOG_INFO, - __FILE__, __LINE__, __func__, - timestamp, NULL, hoststr, initmsg, - data); - VIR_FREE(hoststr); - VIR_FREE(initmsg); + g_autofree char *hoststr =3D NULL; + + /* put some useful info at the top of the log. Avoid calling + * any function that might end up reporting an error or + * otherwise logging something, to prevent recursion. + */ + + virLogOneInitMsg(timestamp, VIR_LOG_VERSION_STRING, outputFunc, da= ta); + + hoststr =3D g_strdup_printf("hostname: %s", g_get_host_name()); + virLogOneInitMsg(timestamp, hoststr, outputFunc, data); + *needInit =3D false; } =20 --=20 2.53.0 From nobody Wed Apr 15 07:03:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775621655; cv=none; d=zohomail.com; s=zohoarc; b=OpZw62+47ShWCsr0lvn8Q6BkMpOyTptqDzI7oL1JX6FdGTkPR8cEWE5Te3+cQwjHJyfh6k9SAHH+fjSsIP/yDU5Nac6/hJbL1Q3XpPCy5UxqYcWlfs+XlppQPVy/yGjxsrfhLUUPWXu+b8cTp95dhn2y9zT+Xv6A0isRwtY2//Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775621655; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=p6eTLizROotziu0TYxJ9y8WezmSmD1/Ys4bbH03pz1g=; b=Wtj/fxvxiyk48pODdp0lrj5DVhPauTXAbKkCdDbVscqOKX43mTmkrhnK3yvVIGGXVVpAzaJjjNkY/pvKER4d9UzwVyTNvnqAUv5C1NsxSVZSI6TFWogFHDG+Mu9ruqoq/WAc2+cspEtOKa9pCAtNeX/pTgU9Dp9sN/MSSDpJnzA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1775621655006991.8903421476391; Tue, 7 Apr 2026 21:14:15 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 85768418A7; Wed, 8 Apr 2026 00:14:14 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 11E3B41AD3; Wed, 8 Apr 2026 00:10:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id EB7F43F35F; Wed, 8 Apr 2026 00:10:46 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3D2F93F2F5 for ; Wed, 8 Apr 2026 00:10:46 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-352-2dhFypFeNBS3GmpaIh5bRg-1; Wed, 08 Apr 2026 00:10:43 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F15651956080 for ; Wed, 8 Apr 2026 04:10:42 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A05D300019F for ; Wed, 8 Apr 2026 04:10:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775621445; h=from:from: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; bh=p6eTLizROotziu0TYxJ9y8WezmSmD1/Ys4bbH03pz1g=; b=hj0v6v/d0PclEfx09h4dEFMlQzkY6guq7NvJzM4MBha3a4oV06MPmvVl4N8TysCEv34Pbv tfUTEnI0GJYCBapjAWYHEZo4qBsb/2P+70oH9wbiwKK3lkq/1LX3OvwKcE6/y8eDQOCxb1 HiFDRXht4WiwGm4cBZatoRJgS2PF0Dw= X-MC-Unique: 2dhFypFeNBS3GmpaIh5bRg-1 X-Mimecast-MFC-AGG-ID: 2dhFypFeNBS3GmpaIh5bRg_1775621443 To: devel@lists.libvirt.org Subject: [PATCH v2 5/6] util: add info to log banner about uid and user environment Date: Wed, 8 Apr 2026 00:10:37 -0400 Message-ID: <20260408041038.424650-6-laine@redhat.com> In-Reply-To: <20260408041038.424650-1-laine@redhat.com> References: <20260408041038.424650-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vUq07o86Wi9Z0YWupnsu2ws7IBgQ7ldS3XlVnJAP8j8_1775621443 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VKNIN36PPKCMOAO3UB7RK6AGCYPLPI25 X-Message-ID-Hash: VKNIN36PPKCMOAO3UB7RK6AGCYPLPI25 X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775621655882154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump As libvirt is used more and more in unprivileged/session mode, file/socket permission errors have become more common. This patch adds the username and uid of the process to the line in the log banner (the first thing sent to every log target after the process starts) that previously just gave the hostname. We can expand on this idea to include more generally useful info about the environment we're running in. (We just need to remember that in this context we can't call anything that could lead to recursively calling the logging system (i.e. we can't call any code that reports an error, or a VIR_WARN, etc)) Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- V2: removed all the "unprivileged/session mode" stuff as suggested by Daniel. Now we just add user and uid to the existing hostname line src/util/virlog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index cab23f613f..ccdf66c396 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -526,16 +526,18 @@ virLogToOneTarget(virLogSource *source, bool *needInit) { if (*needInit) { + uid_t uid =3D geteuid(); + g_autofree char *username =3D virGetUserName(uid); g_autofree char *hoststr =3D NULL; =20 /* put some useful info at the top of the log. Avoid calling * any function that might end up reporting an error or * otherwise logging something, to prevent recursion. */ - virLogOneInitMsg(timestamp, VIR_LOG_VERSION_STRING, outputFunc, da= ta); =20 - hoststr =3D g_strdup_printf("hostname: %s", g_get_host_name()); + hoststr =3D g_strdup_printf("hostname: %s, user: %s, uid: %u", + g_get_host_name(), username, uid); virLogOneInitMsg(timestamp, hoststr, outputFunc, data); =20 *needInit =3D false; --=20 2.53.0 From nobody Wed Apr 15 07:03:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775621623; cv=none; d=zohomail.com; s=zohoarc; b=FkiL5w/9uia75p890ty1WhqWUFb63hGR+guOGzwRcEJjMYSWWJ1lXMZkK9mQ0zklbhlQ1E3c+ptSm9cBz40vHe2ORsJnc7epK9v3sf+0LwjqfySoPe6Q4dx09zzUNZVf2k+h8xEe2XvSssU1xkYOTmNk5Xa8xJR3JCgFO0unF88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775621623; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=587SR332kfH6hKpBFW+aS4vZeWHp8aGyA06ks3hNXfY=; b=lodzvhw2wWydKJAmr4EHrvXRhhulUFf2s3jjfoQhefKnoKpuR6Ov+N1VlH0BDZprTA5SNbE5sAn7rA6RKt+rFWXJ1aSeXyWumOkD0L9SZTA787ekt/auqFPbovCcqucN5LfdWpC4/T22xgLQiwtuDCSZw2ZMteJTdxELqFmtxWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1775621623054243.99262381003894; Tue, 7 Apr 2026 21:13:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 278824193D; Wed, 8 Apr 2026 00:13:42 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 1167F41A7A; Wed, 8 Apr 2026 00:10:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id DAD163F35F; Wed, 8 Apr 2026 00:10:46 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7F5B73F8B4 for ; Wed, 8 Apr 2026 00:10:46 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-ESuntEVvM5C3ULx_f0uVmA-1; Wed, 08 Apr 2026 00:10:44 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 87AE219560B4 for ; Wed, 8 Apr 2026 04:10:43 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.64.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2FE48300019F for ; Wed, 8 Apr 2026 04:10:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775621446; h=from:from: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; bh=587SR332kfH6hKpBFW+aS4vZeWHp8aGyA06ks3hNXfY=; b=EbJsLI4ieqISWFUHC/WFSaRgJwiu6zhk4dXA9eKYQGS68MiCVd9N9Vch10nHk2d3Pw7fSa MdUl3guEUM1AyNXiUOrZgbXYiJh2bjUGokFU9uTFT3dAKtrqGjl9l0aDJZezJNl0N7Erl+ uC3vzPu5fKvC44jlhZEpFoLC0wgWtHc= X-MC-Unique: ESuntEVvM5C3ULx_f0uVmA-1 X-Mimecast-MFC-AGG-ID: ESuntEVvM5C3ULx_f0uVmA_1775621443 To: devel@lists.libvirt.org Subject: [PATCH v2 6/6] util: add info about g_get_user_*_dir directories to log banner Date: Wed, 8 Apr 2026 00:10:38 -0400 Message-ID: <20260408041038.424650-7-laine@redhat.com> In-Reply-To: <20260408041038.424650-1-laine@redhat.com> References: <20260408041038.424650-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5E9HC3vw7SAtBMveYNBAsVLlTiAOqpmm8UAqdUo1msQ_1775621443 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WYKOMKKBDPEM2WJO6FYZJVPG4WCJTNXV X-Message-ID-Hash: WYKOMKKBDPEM2WJO6FYZJVPG4WCJTNXV X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775621625063158501 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Laine Stump When running in session/unprivileged mode, nearly all paths are prefixed with the returns from one of glib's g_get_user_*_dir() functions, which in turn base their selected paths on the settings of a few items in the user's environment ($XDG_*, or a subdirectory of $HOME if the relevant $XDG_* isn't set). This patch logs the settings of these directories in the log banner in an attempt to help diagnose the problem when a file/socket open/create fails. An example of the banner: libvirt version: 12.3.0, package: 1.fc43 (Unknown, 2026-04-07-22:43:30, vho= st) hostname: 83be0e173e02, user: qemu, uid: 107 home dir: '/' (HOME=3D'/') runtime dir: '/.cache' (XDG_RUNTIME_DIR=3D'(unset)') config dir: '/.config' (XDG_CONFIG_HOME=3D'(unset)') log dir: '/.cache' (XDG_CACHE_HOME=3D'(unset)') libvirt: XML-RPC error : Cannot create user runtime directory '/.cache/libv= irt': Permission denied Resolves: https://redhat.atlassian.net/browse/RHEL-70222 Resolves: https://redhat.atlassian.net/browse/RHEL-105490 Signed-off-by: Laine Stump Reviewed-by: Peter Krempa --- We could obviously add more information here (or less); it's difficult to know where to draw the line. Also, the astute reviewer will notice that all this code is executed once for each log target - we could do it all once at a higher level and cache it if we really wanted to. I'm not sure if it's worth the trouble though). Changes in V2: modified the format/labeling of the data as Peter suggested, and included an example in the commit log. src/util/virlog.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/util/virlog.c b/src/util/virlog.c index ccdf66c396..d2882d16ee 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -540,6 +540,43 @@ virLogToOneTarget(virLogSource *source, g_get_host_name(), username, uid); virLogOneInitMsg(timestamp, hoststr, outputFunc, data); =20 + /* This info is only relevant when running as something other than= root */ + if (uid !=3D 0) { + g_autofree char *envHOME =3D NULL; + g_autofree char *envXDG_RUNTIME_DIR =3D NULL; + g_autofree char *envXDG_CONFIG_HOME =3D NULL; + g_autofree char *envXDG_CACHE_HOME =3D NULL; + + g_autofree char *envstr1 =3D NULL; + g_autofree char *envstr2 =3D NULL; + g_autofree char *envstr3 =3D NULL; + g_autofree char *envstr4 =3D NULL; + + if (!(envHOME =3D g_strdup(g_getenv("HOME")))) + envHOME =3D g_strdup("(unset)"); + if (!(envXDG_RUNTIME_DIR =3D g_strdup(g_getenv("XDG_RUNTIME_DI= R")))) + envXDG_RUNTIME_DIR =3D g_strdup("(unset)"); + if (!(envXDG_CONFIG_HOME =3D g_strdup(g_getenv("XDG_CONFIG_HOM= E")))) + envXDG_CONFIG_HOME =3D g_strdup("(unset)"); + if (!(envXDG_CACHE_HOME =3D g_strdup(g_getenv("XDG_CACHE_HOME"= )))) + envXDG_CACHE_HOME =3D g_strdup("(unset)"); + + envstr1 =3D g_strdup_printf("home dir: '%s' (HOME=3D'%s')", + g_get_home_dir(), envHOME); + virLogOneInitMsg(timestamp, envstr1, outputFunc, data); + + envstr2 =3D g_strdup_printf("runtime dir: '%s' (XDG_RUNTIME_DI= R=3D'%s')", + g_get_user_runtime_dir(), envXDG_RUN= TIME_DIR); + virLogOneInitMsg(timestamp, envstr2, outputFunc, data); + + envstr3 =3D g_strdup_printf("config dir: '%s' (XDG_CONFIG_HOME= =3D'%s')", + g_get_user_config_dir(), envXDG_CONF= IG_HOME); + virLogOneInitMsg(timestamp, envstr3, outputFunc, data); + + envstr4 =3D g_strdup_printf("log dir: '%s' (XDG_CACHE_HOME=3D'= %s')", + g_get_user_cache_dir(), envXDG_CACHE= _HOME); + virLogOneInitMsg(timestamp, envstr4, outputFunc, data); + } *needInit =3D false; } =20 --=20 2.53.0