From nobody Mon Feb 9 11:29:31 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=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1675090928; cv=none; d=zohomail.com; s=zohoarc; b=RnJyhQ3YbZs1goife4UK3ksZpeg6UFm7jbFvnONo+16jcKAzRShod2JC9LrFpCMDI+1PrJAYtS1l5Ta9Cj7cDFo0OX8zD47P4DhQ0ezEbes8RRad6yywYIFT27kCIvvB7k6EY6iUHSM5g2+bWCmF7VM9Uy1Y75fPfzAHRGYiGis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675090928; h=Content-Type:Content-Transfer-Encoding:Cc: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=06HtmV5hruxtT7pjZlOeB7IUL3byx5NRNKP4z3pXce4=; b=nXTH9AgKEme/IRQnXQw+Q/HzGvkmIkTUAshvAF9eksSbzRolF4kQXiNORVRHRRR3Z0W2KvustdxS803+4qjB/lxppI6wzeVcGhAWNZL6MPn2ge6uLIUED81ggUmAfKoRkFV0wscGAmXoBtIT4q4/SJ4Ka6Wret3hik/bHrXEohc= 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=fail header.from= (p=quarantine dis=quarantine) 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 1675090928212868.4029705462024; Mon, 30 Jan 2023 07:02:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-JjTgl7lXO3Cg7e6Lh2W0vw-1; Mon, 30 Jan 2023 10:01:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4CB63C0F668; Mon, 30 Jan 2023 15:00:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9800F1121314; Mon, 30 Jan 2023 15:00:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 447D41946589; Mon, 30 Jan 2023 15:00:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5B10F1946587 for ; Mon, 30 Jan 2023 15:00:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3EB4C140EBF6; Mon, 30 Jan 2023 15:00:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 371DB140EBF5 for ; Mon, 30 Jan 2023 15:00:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 0891185CBE3 for ; Mon, 30 Jan 2023 15:00:28 +0000 (UTC) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-205-pFfIdx73Pb2kcB7oAz-39A-1; Mon, 30 Jan 2023 10:00:24 -0500 Received: from [192.168.16.74] (helo=dv.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1pMVdp-00AYfM-RS; Mon, 30 Jan 2023 16:00:18 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675090871; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=06HtmV5hruxtT7pjZlOeB7IUL3byx5NRNKP4z3pXce4=; b=F9IVzqhWRs0jRRtEQHnC2Qscp+JsbccPi/ySS7EsTDdFj9FS1znDsKM7cOw08uP0li64wR sQ9HfACO6RMMbkPw1zjApcyQbGuHIXf2UW8Rh4bswv0bQWhwjsXqQ/mFxHSSorSUCdC53y eH5V/XzVMXjeFgr5oDV7kT/c8tVgPWo= X-MC-Unique: JjTgl7lXO3Cg7e6Lh2W0vw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: pFfIdx73Pb2kcB7oAz-39A-1 From: Oleg Vasilev To: libvir-list@redhat.com Subject: [PATCH v3 1/5] logging: refactor to store config inside log handler Date: Mon, 30 Jan 2023 20:59:58 +0600 Message-Id: <20230130150002.322315-2-oleg.vasilev@virtuozzo.com> In-Reply-To: <20230130150002.322315-1-oleg.vasilev@virtuozzo.com> References: <20230130150002.322315-1-oleg.vasilev@virtuozzo.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Kletzander , Den Lunev , Oleg Vasilev Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1675090941832100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Oleg Vasilev --- src/logging/log_daemon.c | 6 ++---- src/logging/log_handler.c | 29 ++++++++++++----------------- src/logging/log_handler.h | 17 ++++++++--------- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 9b70ffad2f..8025245350 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -145,8 +145,7 @@ virLogDaemonNew(virLogDaemonConfig *config, bool privil= eged) g_clear_pointer(&srv, virObjectUnref); =20 if (!(logd->handler =3D virLogHandlerNew(privileged, - config->max_size, - config->max_backups, + config, virLogDaemonInhibitor, logd))) goto error; @@ -231,8 +230,7 @@ virLogDaemonNewPostExecRestart(virJSONValue *object, bo= ol privileged, =20 if (!(logd->handler =3D virLogHandlerNewPostExecRestart(child, privileged, - config->max_size, - config->max_back= ups, + config, virLogDaemonInhi= bitor, logd))) goto error; diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index bf1e3f35c5..7342404b00 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -58,8 +58,7 @@ struct _virLogHandler { virObjectLockable parent; =20 bool privileged; - size_t max_size; - size_t max_backups; + virLogDaemonConfig *config; =20 virLogHandlerLogFile **files; size_t nfiles; @@ -185,8 +184,7 @@ virLogHandlerDomainLogFileEvent(int watch, =20 virLogHandler * virLogHandlerNew(bool privileged, - size_t max_size, - size_t max_backups, + virLogDaemonConfig *config, virLogHandlerShutdownInhibitor inhibitor, void *opaque) { @@ -199,8 +197,7 @@ virLogHandlerNew(bool privileged, return NULL; =20 handler->privileged =3D privileged; - handler->max_size =3D max_size; - handler->max_backups =3D max_backups; + handler->config =3D config; handler->inhibitor =3D inhibitor; handler->opaque =3D opaque; =20 @@ -253,8 +250,8 @@ virLogHandlerLogFilePostExecRestart(virLogHandler *hand= ler, } =20 if ((file->file =3D virRotatingFileWriterNew(path, - handler->max_size, - handler->max_backups, + handler->config->max_size, + handler->config->max_backup= s, false, DEFAULT_MODE)) =3D=3D NULL) goto error; @@ -282,8 +279,7 @@ virLogHandlerLogFilePostExecRestart(virLogHandler *hand= ler, virLogHandler * virLogHandlerNewPostExecRestart(virJSONValue *object, bool privileged, - size_t max_size, - size_t max_backups, + virLogDaemonConfig *config, virLogHandlerShutdownInhibitor inhibitor, void *opaque) { @@ -292,8 +288,7 @@ virLogHandlerNewPostExecRestart(virJSONValue *object, size_t i; =20 if (!(handler =3D virLogHandlerNew(privileged, - max_size, - max_backups, + config, inhibitor, opaque))) return NULL; @@ -393,8 +388,8 @@ virLogHandlerDomainOpenLogFile(virLogHandler *handler, file->domname =3D g_strdup(domname); =20 if ((file->file =3D virRotatingFileWriterNew(path, - handler->max_size, - handler->max_backups, + handler->config->max_size, + handler->config->max_backup= s, trunc, DEFAULT_MODE)) =3D=3D NULL) goto error; @@ -525,7 +520,7 @@ virLogHandlerDomainReadLogFile(virLogHandler *handler, =20 virObjectLock(handler); =20 - if (!(file =3D virRotatingFileReaderNew(path, handler->max_backups))) + if (!(file =3D virRotatingFileReaderNew(path, handler->config->max_bac= kups))) goto error; =20 if (virRotatingFileReaderSeek(file, inode, offset) < 0) @@ -579,8 +574,8 @@ virLogHandlerDomainAppendLogFile(virLogHandler *handler, =20 if (!writer) { if (!(newwriter =3D virRotatingFileWriterNew(path, - handler->max_size, - handler->max_backups, + handler->config->max_si= ze, + handler->config->max_ba= ckups, false, DEFAULT_MODE))) goto cleanup; diff --git a/src/logging/log_handler.h b/src/logging/log_handler.h index 099378b361..c9af033cd3 100644 --- a/src/logging/log_handler.h +++ b/src/logging/log_handler.h @@ -22,6 +22,7 @@ =20 #include "internal.h" #include "virjson.h" +#include "log_daemon_config.h" =20 typedef struct _virLogHandler virLogHandler; =20 @@ -30,16 +31,14 @@ typedef void (*virLogHandlerShutdownInhibitor)(bool inh= ibit, void *opaque); =20 virLogHandler *virLogHandlerNew(bool privileged, - size_t max_size, - size_t max_backups, - virLogHandlerShutdownInhibitor inhibitor, - void *opaque); + virLogDaemonConfig *config, + virLogHandlerShutdownInhibitor inhibitor, + void *opaque); virLogHandler *virLogHandlerNewPostExecRestart(virJSONValue *child, - bool privileged, - size_t max_size, - size_t max_backups, - virLogHandlerShutdownInhi= bitor inhibitor, - void *opaque); + bool privileged, + virLogDaemonConfig *config, + virLogHandlerShutdownInhibi= tor inhibitor, + void *opaque); =20 void virLogHandlerFree(virLogHandler *handler); =20 --=20 2.39.1