From nobody Mon Feb 9 08:56:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1675090904; cv=none; d=zohomail.com; s=zohoarc; b=AVG/BUnzsdcLswvDRgBJW+bEzh/Wa8XF3pM6EzK8CksCNM20hj8C026HI3Wv8xEdph1edcDf58QbnksIhp6Dq13Aj0giuk6HyhpBK61yZvYhsK2NKBt+WpC7FFyJR5VoPiBPLkcUG1Xx9JLHTOP6Qku4TwjL1qSeaEn5qYgvY1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675090904; 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=O87h54K/5VMU8bfCqEjj6aBCEdAsre1omfuPiyL91z4=; b=lRmvC4eeUuZot0Fig/QNKHIxRvGoRzG8IHOov/L+BDXQvF0iHZmqSy/mw/ndGeaAJY+SaQ7HSsirQns9tL2NlJIc3SsmP97eGGx/kp5xe5P67wLFoylkpv9JmlyDHiHehNC5l3DqOkP6Q6zl2IkTQfn/jZjhl6UpbJeVCco57ck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1675090904381744.3865691411368; Mon, 30 Jan 2023 07:01:44 -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-449-0xzjd0U2OAinAaGKE0mUCw-1; Mon, 30 Jan 2023 10:01:39 -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 0F04129A9D4C; Mon, 30 Jan 2023 15:00:54 +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 EBF7F1121314; Mon, 30 Jan 2023 15:00:53 +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 BAD21194658F; Mon, 30 Jan 2023 15:00:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EB4DF1946587 for ; Mon, 30 Jan 2023 15:00:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DF21D492B01; Mon, 30 Jan 2023 15:00:33 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7646492B00 for ; Mon, 30 Jan 2023 15:00:33 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 BB9523C0F696 for ; Mon, 30 Jan 2023 15:00:33 +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-148-gckIwK1QMAiGGxQ1b9mGGQ-1; Mon, 30 Jan 2023 10:00:28 -0500 Received: from [192.168.16.74] (helo=dv.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1pMVdr-00AYfM-SV; Mon, 30 Jan 2023 16:00:20 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675090903; 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=O87h54K/5VMU8bfCqEjj6aBCEdAsre1omfuPiyL91z4=; b=VFPE20hE38IMZqExu3lOLvBUZDEqSDqeEljhn7Qa66EmYBYd+jVaImE6iK0vqmJnFh9YZZ NUC1ned1TV79Gu8xSm13g79RYjeT47QufWzP+DoS21tBX2KsFfnOMm4P3sob1iXZtivYqp rDFnSLHBkor2NXL6TVl0vmIKu2fpBtA= X-MC-Unique: 0xzjd0U2OAinAaGKE0mUCw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: gckIwK1QMAiGGxQ1b9mGGQ-1 From: Oleg Vasilev To: libvir-list@redhat.com Subject: [PATCH v3 3/5] logging: add configuration for future log cleaner Date: Mon, 30 Jan 2023 21:00:00 +0600 Message-Id: <20230130150002.322315-4-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.10 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: 1675090910619100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We want to specify the folder to clean and how much time can a log chain live. Signed-off-by: Oleg Vasilev --- src/logging/log_daemon_config.c | 9 +++++++++ src/logging/log_daemon_config.h | 3 +++ src/logging/test_virtlogd.aug.in | 2 ++ src/logging/virtlogd.aug | 2 ++ src/logging/virtlogd.conf | 14 ++++++++++++++ 5 files changed, 30 insertions(+) diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_confi= g.c index 4436745488..248bd927d3 100644 --- a/src/logging/log_daemon_config.c +++ b/src/logging/log_daemon_config.c @@ -28,6 +28,7 @@ #include "virutil.h" =20 #define VIR_FROM_THIS VIR_FROM_CONF +#define DEFAULT_LOG_ROOT LOCALSTATEDIR "/log/libvirt/" =20 VIR_LOG_INIT("logging.log_daemon_config"); =20 @@ -60,6 +61,7 @@ virLogDaemonConfigNew(bool privileged G_GNUC_UNUSED) data->admin_max_clients =3D 5000; data->max_size =3D 1024 * 1024 * 2; data->max_backups =3D 3; + data->max_age_days =3D 0; =20 return data; } @@ -72,6 +74,7 @@ virLogDaemonConfigFree(virLogDaemonConfig *data) =20 g_free(data->log_filters); g_free(data->log_outputs); + g_free(data->log_root); =20 g_free(data); } @@ -94,6 +97,12 @@ virLogDaemonConfigLoadOptions(virLogDaemonConfig *data, return -1; if (virConfGetValueSizeT(conf, "max_backups", &data->max_backups) < 0) return -1; + if (virConfGetValueSizeT(conf, "max_age_days", &data->max_age_days) < = 0) + return -1; + if (virConfGetValueString(conf, "log_root", &data->log_root) < 0) + return -1; + if (!data->log_root) + data->log_root =3D g_strdup(DEFAULT_LOG_ROOT); =20 return 0; } diff --git a/src/logging/log_daemon_config.h b/src/logging/log_daemon_confi= g.h index 2ab0f67c96..43922feedf 100644 --- a/src/logging/log_daemon_config.h +++ b/src/logging/log_daemon_config.h @@ -33,6 +33,9 @@ struct _virLogDaemonConfig { =20 size_t max_backups; size_t max_size; + + char *log_root; + size_t max_age_days; }; =20 =20 diff --git a/src/logging/test_virtlogd.aug.in b/src/logging/test_virtlogd.a= ug.in index cd5b0d91f8..8dfad39506 100644 --- a/src/logging/test_virtlogd.aug.in +++ b/src/logging/test_virtlogd.aug.in @@ -9,3 +9,5 @@ module Test_virtlogd =3D { "admin_max_clients" =3D "5" } { "max_size" =3D "2097152" } { "max_backups" =3D "3" } + { "max_age_days" =3D "0" } + { "log_root" =3D "/var/log/libvirt" } diff --git a/src/logging/virtlogd.aug b/src/logging/virtlogd.aug index 0f1b290c72..bdf61dea6e 100644 --- a/src/logging/virtlogd.aug +++ b/src/logging/virtlogd.aug @@ -31,6 +31,8 @@ module Virtlogd =3D | int_entry "admin_max_clients" | int_entry "max_size" | int_entry "max_backups" + | int_entry "max_age_days" + | str_entry "log_root" =20 (* Each entry in the config is one of the following three ... *) let entry =3D logging_entry diff --git a/src/logging/virtlogd.conf b/src/logging/virtlogd.conf index c53a1112bd..5214e96121 100644 --- a/src/logging/virtlogd.conf +++ b/src/logging/virtlogd.conf @@ -101,3 +101,17 @@ # Maximum number of backup files to keep. Defaults to 3, # not including the primary active file #max_backups =3D 3 + +# Maximum age for log files to live after the last modification. +# Defaults to 0, which means "forever". +# +# WARNING: since virtlogd has no way to differentiate which files it used = to +# manage, the garbage collection mechanism will collect ALL files, once it= s age +# reach max_age_days. Use only if you know what you mean. +#max_age_days =3D 0 + +# Root of all logs managed by virtlogd. Used to GC logs from obsolete mach= ines. +# +# WARNING: all files under this location potentially can be GC-ed. See the +# warning for max_age_days. +#log_root =3D "/var/log/libvirt" --=20 2.39.1