From nobody Sat Feb 7 15:11: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=1655128614; cv=none; d=zohomail.com; s=zohoarc; b=DeeCYFOw18rJk4oOjW8hg0W9jA9hVSawYiAE1AC6lyDoetlwJsBIa4vANQG9M0O6LT5k//VYapZhVJSTL/Fhb22mzGUFveBjuSMu8573zjyUe7XpaM/QSahHPJibbZYPwtG+/gIsJjy8B3QjFuQctdcLQQ5rhI3y2Z99p4qovms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655128614; 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=cBcdpTBhKXnrfoBSuhkxffugH/zjFhvtTtThcw6vMKw=; b=EnVGdYQfntHzOP1I0sx1aU0huSu3jtfV2/C9wqomMgHbNR+PxvGd2/Gb3H5rTVbwh3TUs9sXYdL63sn+AF6z5lHy0UT/gIRlOE1o5S5xB/7tiN4PH1+tiayd6M1lkq9IPs/4Y3nLQzveJvh/31FuvXtGAjo/BhpcoEK22swhKVM= 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 1655128614549341.94083394626534; Mon, 13 Jun 2022 06:56:54 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-VOA4aCV9N_uyy_6E8LQ4eg-1; Mon, 13 Jun 2022 09:56:50 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1854B811E90; Mon, 13 Jun 2022 13:56:47 +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 0598940CFD0B; Mon, 13 Jun 2022 13:56:47 +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 C88AA1947062; Mon, 13 Jun 2022 13:56:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3F20D1947062 for ; Mon, 13 Jun 2022 13:56:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 20970492CA4; Mon, 13 Jun 2022 13:56:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F1C1492CA2 for ; Mon, 13 Jun 2022 13:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655128613; 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=cBcdpTBhKXnrfoBSuhkxffugH/zjFhvtTtThcw6vMKw=; b=Y1Wdaij9758VxebF1wYOzDGStMhrjEPGUD7KIx06VK1WYGbCebZZ3HxssuVAwwJ9OUgWDh Wrd8TP4z9uoPzGwPZ3Fh7HfR0cfF09v8lM4J/OuzOuZQk+DwuPFD6fir1bbDBP8cA6luqA oc4F9iCtCjb17UkGo6IOewluxG7lCHI= X-MC-Unique: VOA4aCV9N_uyy_6E8LQ4eg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/6] virnetdaemon: Extract autoShutdownTimer operations from virNetDaemonRun Date: Mon, 13 Jun 2022 15:56:28 +0200 Message-Id: <8b993870b6cadebe341618f86ee69a79e9266034.1655128518.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: 1655128616311100003 Content-Type: text/plain; charset="utf-8" Introduce 'virNetDaemonShutdownTimerRegister' and 'virNetDaemonShutdownTimerUpdate' to aggregate the code to deal with the auto-shutdown timer. The code is also placed so that it can be called from 'virNetDaemonAutoShutdown' which involved the move of 'virNetDaemonAutoShutdownTimer'. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/rpc/virnetdaemon.c | 108 +++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 42 deletions(-) diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 1f32bae35f..7bf27eed9d 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -77,6 +77,8 @@ struct _virNetDaemon { bool execRestart; unsigned int autoShutdownTimeout; + int autoShutdownTimerID; + bool autoShutdownTimerActive; size_t autoShutdownInhibitions; int autoShutdownInhibitFd; }; @@ -153,6 +155,8 @@ virNetDaemonNew(void) if (virEventRegisterDefaultImpl() < 0) goto error; + dmn->autoShutdownTimerID =3D -1; + #ifndef WIN32 memset(&sig_action, 0, sizeof(sig_action)); sig_action.sa_handler =3D SIG_IGN; @@ -403,6 +407,65 @@ virNetDaemonIsPrivileged(virNetDaemon *dmn) } +static void +virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED, + void *opaque) +{ + virNetDaemon *dmn =3D opaque; + VIR_LOCK_GUARD lock =3D virObjectLockGuard(dmn); + + if (!dmn->autoShutdownInhibitions) { + VIR_DEBUG("Automatic shutdown triggered"); + dmn->quit =3D true; + } +} + + +static int +virNetDaemonShutdownTimerRegister(virNetDaemon *dmn) +{ + if (dmn->autoShutdownTimeout =3D=3D 0) + return 0; + + if ((dmn->autoShutdownTimerID =3D virEventAddTimeout(-1, + virNetDaemonAutoShu= tdownTimer, + dmn, NULL)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to register shutdown timeout")); + return -1; + } + + return 0; +} + + +static void +virNetDaemonShutdownTimerUpdate(virNetDaemon *dmn) +{ + if (dmn->autoShutdownTimeout =3D=3D 0) + return; + + /* A shutdown timeout is specified, so check + * if any drivers have active state, if not + * shutdown after timeout seconds + */ + if (dmn->autoShutdownTimerActive) { + if (virNetDaemonHasClients(dmn)) { + VIR_DEBUG("Deactivating shutdown timer %d", dmn->autoShutdownT= imerID); + virEventUpdateTimeout(dmn->autoShutdownTimerID, -1); + dmn->autoShutdownTimerActive =3D false; + } + } else { + if (!virNetDaemonHasClients(dmn)) { + VIR_DEBUG("Activating shutdown timer %d", dmn->autoShutdownTim= erID); + virEventUpdateTimeout(dmn->autoShutdownTimerID, + dmn->autoShutdownTimeout * 1000); + dmn->autoShutdownTimerActive =3D true; + } + } +} + + void virNetDaemonAutoShutdown(virNetDaemon *dmn, unsigned int timeout) @@ -657,19 +720,6 @@ virNetDaemonAddSignalHandler(virNetDaemon *dmn G_GNUC_= UNUSED, #endif /* WIN32 */ -static void -virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED, - void *opaque) -{ - virNetDaemon *dmn =3D opaque; - VIR_LOCK_GUARD lock =3D virObjectLockGuard(dmn); - - if (!dmn->autoShutdownInhibitions) { - VIR_DEBUG("Automatic shutdown triggered"); - dmn->quit =3D true; - } -} - static int daemonServerUpdateServices(void *payload, const char *key G_GNUC_UNUSED, @@ -743,11 +793,10 @@ virNetDaemonFinishTimer(int timerid G_GNUC_UNUSED, dmn->finished =3D true; } + void virNetDaemonRun(virNetDaemon *dmn) { - int timerid =3D -1; - bool timerActive =3D false; virThread shutdownThread; virObjectLock(dmn); @@ -763,14 +812,8 @@ virNetDaemonRun(virNetDaemon *dmn) dmn->finished =3D false; dmn->graceful =3D false; - if (dmn->autoShutdownTimeout && - (timerid =3D virEventAddTimeout(-1, - virNetDaemonAutoShutdownTimer, - dmn, NULL)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to register shutdown timeout")); + if (virNetDaemonShutdownTimerRegister(dmn) < 0) goto cleanup; - } /* We are accepting connections now. Notify systemd * so it can start dependent services. */ @@ -778,26 +821,7 @@ virNetDaemonRun(virNetDaemon *dmn) VIR_DEBUG("dmn=3D%p quit=3D%d", dmn, dmn->quit); while (!dmn->finished) { - /* A shutdown timeout is specified, so check - * if any drivers have active state, if not - * shutdown after timeout seconds - */ - if (dmn->autoShutdownTimeout) { - if (timerActive) { - if (virNetDaemonHasClients(dmn)) { - VIR_DEBUG("Deactivating shutdown timer %d", timerid); - virEventUpdateTimeout(timerid, -1); - timerActive =3D false; - } - } else { - if (!virNetDaemonHasClients(dmn)) { - VIR_DEBUG("Activating shutdown timer %d", timerid); - virEventUpdateTimeout(timerid, - dmn->autoShutdownTimeout * 1000); - timerActive =3D true; - } - } - } + virNetDaemonShutdownTimerUpdate(dmn); virObjectUnlock(dmn); if (virEventRunDefaultImpl() < 0) { --=20 2.36.1 From nobody Sat Feb 7 15:11: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=1655128615; cv=none; d=zohomail.com; s=zohoarc; b=bj9MIAgUqbacJHMcOTSoNPAn6RuNhXvik9dIgaf6PdjfBC39DAAJygpAkGw2JLGOv8Akr0OD6T5bP78qlUqeDXAf/jTTObTB4ZbQC4S2mVth0/8TV8GKodGmP/7n031IxbVSvfPpAjq68rRwiYcVSrz1HTNlpwIHBSl+VHChkwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655128615; 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=MaTqDCRUuifQrl9iyYdio+9gs3JSwAoBBfNLfF5P/+M=; b=lFQEnPookrBMB1gK7iTSOg4ufDDk5jpoxVk4CcyQmQJ/DSn7uO8zT/U9wr52y4LRueoLwvg5BBA91i2uec3d16P5g6wGiJsAQcppYt+i8ENR7rMg2kG2YYTunCwHMT9OuBUIgPZp43v7uWh+3HtfUWfTCHpTZSihdUekSp/4BSI= 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 1655128614962136.39912707813517; Mon, 13 Jun 2022 06:56:54 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-182-s4Udda4DO1uQ-2Wc2nqazw-1; Mon, 13 Jun 2022 09:56:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D22FE1066568; Mon, 13 Jun 2022 13:56:47 +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 BD58810725; Mon, 13 Jun 2022 13:56:47 +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 15A5F1947076; Mon, 13 Jun 2022 13:56:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 66D7E194705B for ; Mon, 13 Jun 2022 13:56:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4752E492CA4; Mon, 13 Jun 2022 13:56:46 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80ACF492CA2 for ; Mon, 13 Jun 2022 13:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655128613; 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=MaTqDCRUuifQrl9iyYdio+9gs3JSwAoBBfNLfF5P/+M=; b=V1MT3jTDbChu4iRqweHd2g5Y/eBwGHyt0MGYX0KTfbBHQKeC67LRw3ipJWNomPqadqLigf 9TdzWNzUaL/H7tci3ZgxPpHqMsoCVbriecnCSdjVpSrKK6S/AW3SaP2gqBNYUz4WB2G9CM /m+0cFGTM/E/d/0ZcE0EKi1V8AqRXCo= X-MC-Unique: s4Udda4DO1uQ-2Wc2nqazw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/6] virNetDaemonAutoShutdown: Allow live update of shutdown timeout Date: Mon, 13 Jun 2022 15:56:29 +0200 Message-Id: <694bd62fd510b90956ffa9d9fb5590a28c1fe1cd.1655128518.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1655128616331100004 Content-Type: text/plain; charset="utf-8" Modify the code so that calling 'virNetDaemonAutoShutdown' will update the auto shutdown timeout also for running daemons. This involves changing the logic when to do the update of the timer so that it can be called from both when the daemon is not yet runnign and when doing a live update. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/locking/lock_daemon.c | 5 ++--- src/logging/log_daemon.c | 5 ++--- src/remote/remote_daemon.c | 4 ++-- src/rpc/virnetdaemon.c | 29 +++++++++++++++++++++-------- src/rpc/virnetdaemon.h | 4 ++-- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 75f6c708db..59c110f62b 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -1051,9 +1051,8 @@ int main(int argc, char **argv) { } if (timeout > 0) { - VIR_DEBUG("Registering shutdown timeout %d", timeout); - virNetDaemonAutoShutdown(lockDaemon->dmn, - timeout); + if (virNetDaemonAutoShutdown(lockDaemon->dmn, timeout) < 0) + goto cleanup; } if ((virLockDaemonSetupSignals(lockDaemon->dmn)) < 0) { diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 8ab334ff6d..8345d31a8c 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -859,9 +859,8 @@ int main(int argc, char **argv) { } if (timeout > 0) { - VIR_DEBUG("Registering shutdown timeout %d", timeout); - virNetDaemonAutoShutdown(logDaemon->dmn, - timeout); + if (virNetDaemonAutoShutdown(logDaemon->dmn, timeout) < 0) + return -1; } if ((virLogDaemonSetupSignals(logDaemon->dmn)) < 0) { diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index b8ecc51758..9ad71c37db 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -1126,8 +1126,8 @@ int main(int argc, char **argv) { } if (timeout > 0) { - VIR_DEBUG("Registering shutdown timeout %d", timeout); - virNetDaemonAutoShutdown(dmn, timeout); + if (virNetDaemonAutoShutdown(dmn, timeout) < 0) + goto cleanup; } if ((daemonSetupSignals(dmn)) < 0) { diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 7bf27eed9d..84af1adc06 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -75,6 +75,7 @@ struct _virNetDaemon { bool finished; bool graceful; bool execRestart; + bool running; /* the daemon has reached the running phase */ unsigned int autoShutdownTimeout; int autoShutdownTimerID; @@ -424,7 +425,7 @@ virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED, static int virNetDaemonShutdownTimerRegister(virNetDaemon *dmn) { - if (dmn->autoShutdownTimeout =3D=3D 0) + if (dmn->autoShutdownTimerID !=3D -1) return 0; if ((dmn->autoShutdownTimerID =3D virEventAddTimeout(-1, @@ -442,7 +443,7 @@ virNetDaemonShutdownTimerRegister(virNetDaemon *dmn) static void virNetDaemonShutdownTimerUpdate(virNetDaemon *dmn) { - if (dmn->autoShutdownTimeout =3D=3D 0) + if (dmn->autoShutdownTimerID =3D=3D -1) return; /* A shutdown timeout is specified, so check @@ -450,13 +451,15 @@ virNetDaemonShutdownTimerUpdate(virNetDaemon *dmn) * shutdown after timeout seconds */ if (dmn->autoShutdownTimerActive) { - if (virNetDaemonHasClients(dmn)) { + if (virNetDaemonHasClients(dmn) || + dmn->autoShutdownTimeout =3D=3D 0) { VIR_DEBUG("Deactivating shutdown timer %d", dmn->autoShutdownT= imerID); virEventUpdateTimeout(dmn->autoShutdownTimerID, -1); dmn->autoShutdownTimerActive =3D false; } } else { - if (!virNetDaemonHasClients(dmn)) { + if (!virNetDaemonHasClients(dmn) || + dmn->autoShutdownTimeout !=3D 0) { VIR_DEBUG("Activating shutdown timer %d", dmn->autoShutdownTim= erID); virEventUpdateTimeout(dmn->autoShutdownTimerID, dmn->autoShutdownTimeout * 1000); @@ -466,13 +469,25 @@ virNetDaemonShutdownTimerUpdate(virNetDaemon *dmn) } -void +int virNetDaemonAutoShutdown(virNetDaemon *dmn, unsigned int timeout) { VIR_LOCK_GUARD lock =3D virObjectLockGuard(dmn); + VIR_DEBUG("Registering shutdown timeout %u", timeout); + + if (timeout > 0) { + if (virNetDaemonShutdownTimerRegister(dmn) < 0) + return -1; + } + dmn->autoShutdownTimeout =3D timeout; + + if (dmn->running) + virNetDaemonShutdownTimerUpdate(dmn); + + return 0; } @@ -811,9 +826,7 @@ virNetDaemonRun(virNetDaemon *dmn) dmn->finishTimer =3D -1; dmn->finished =3D false; dmn->graceful =3D false; - - if (virNetDaemonShutdownTimerRegister(dmn) < 0) - goto cleanup; + dmn->running =3D true; /* We are accepting connections now. Notify systemd * so it can start dependent services. */ diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h index f91b59a4fd..bfee155a4b 100644 --- a/src/rpc/virnetdaemon.h +++ b/src/rpc/virnetdaemon.h @@ -49,8 +49,8 @@ virJSONValue *virNetDaemonPreExecRestart(virNetDaemon *dm= n); bool virNetDaemonIsPrivileged(virNetDaemon *dmn); -void virNetDaemonAutoShutdown(virNetDaemon *dmn, - unsigned int timeout); +int virNetDaemonAutoShutdown(virNetDaemon *dmn, + unsigned int timeout) G_GNUC_WARN_UNUSED_RESU= LT; void virNetDaemonAddShutdownInhibition(virNetDaemon *dmn); void virNetDaemonRemoveShutdownInhibition(virNetDaemon *dmn); --=20 2.36.1 From nobody Sat Feb 7 15:11:02 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655128688; cv=none; d=zohomail.com; s=zohoarc; b=fU1wgwg6YhuvBmOtTE4ewtgiRPNVoGGlYegNqteF1UUCxoKquj3W+EMKADoh5/66eQdXQKQUO3r/v8z6i1ktEizvELn/ToTiM5gEE596au9xBooTHIRoERo0aX8CArFIpgP4rAqPSLZzOiggGAn9SlTqJRKGh2KrZUT+0hurd00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655128688; 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=fAYqvCaBZkxPr3omEZkLTXjEQmmUN/pN4K5HyElkVRc=; b=eP621iynxJ9AFVnFX7WWXEUedEkyun6Bs5UThI7tK6BPxMfPBk/8/U08PpBMOUduq+hv/GDpgTLvBV7J/gO7/IMm6t7a31biWnm7UfhuVZ1A1NFdBCFiS78d+4KNl2FwXB/62Bwqs5qrs+tGCOVVN6FvmUKUeHFYkklVfBv8sek= 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=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.129.124]) by mx.zohomail.com with SMTPS id 1655128688289228.2771790943982; Mon, 13 Jun 2022 06:58:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-w9EN63bqOSGJddGat8bMbg-1; Mon, 13 Jun 2022 09:56:52 -0400 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 E86AD101AA4D; Mon, 13 Jun 2022 13:56:49 +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 D4EFA1121314; Mon, 13 Jun 2022 13:56:49 +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 72453194706C; Mon, 13 Jun 2022 13:56:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6C672194705B for ; Mon, 13 Jun 2022 13:56:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5BD58492CA4; Mon, 13 Jun 2022 13:56:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id A70F8492CA2 for ; Mon, 13 Jun 2022 13:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655128687; 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=fAYqvCaBZkxPr3omEZkLTXjEQmmUN/pN4K5HyElkVRc=; b=YOsRzCADE5Z1cusUGbhk3w6TEfyzjwW2BSeDISLqiaAcLP9yrBk1yFus6rQCgrlyS3jWMr kagWQLrH9KEwFYMzPLhtjHgok31W46w1NlBcpPmfrSIN7KjV0C8/t53AXHNS76B9H/x9PR hOcvtudl3C4Pe3TSq2QjQDAdqNDZbYc= X-MC-Unique: w9EN63bqOSGJddGat8bMbg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/6] scripts: apibuild: Improve error when API is missing from symbol file Date: Mon, 13 Jun 2022 15:56:30 +0200 Message-Id: <580fd32a36e44aff55bf3f0b81dee7765edc46e7.1655128518.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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: 1655128688800100001 Content-Type: text/plain; charset="utf-8" Improve: KeyError: 'virAdmConnectSetDaemonTimeout' to Exception: Missing symbol file entry for 'virAdmConnectSetDaemonTimeout' Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- scripts/apibuild.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/apibuild.py b/scripts/apibuild.py index 23a66734ac..c232b4e2c8 100755 --- a/scripts/apibuild.py +++ b/scripts/apibuild.py @@ -2405,6 +2405,8 @@ class docBuilder: # NB: this is consumed by a regex in 'getAPIFilenames' in hvsuppor= t.pl if id.type =3D=3D "function": + if name not in self.versions: + raise Exception("Missing symbol file entry for '%s'" % nam= e) ver =3D self.versions[name] if ver is None: raise Exception("Missing version for '%s'" % name) --=20 2.36.1 From nobody Sat Feb 7 15:11: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=1655128624; cv=none; d=zohomail.com; s=zohoarc; b=JcbeDStmT/O5FuuOzBZPTRW5WEdfQwlQ7xQDX0bQbEDMKqUlCV+IodT3jy3XidBCqrg/JOJvp6rXZSWETMzvlEs48L4IYh78NF4S3uDmg02ywS8VGOP51Gv4WCzzKPpTDtlsFiom4XB8ZC8/IxKpHM72+JIWFbAAOoqZEMX+tx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655128624; 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=wofBAGe3HP2jVohjgHN8mheXlpLj6wD7+cS4UrIx/X8=; b=ALePiNlXl3EKCd7ybhaHoApHKvfFim46XpLdMdCskNjI4jFPXe2ctApc0nncDgsBKIwVAB5YhRwOLW0NLixqT+R0Ys9McOiDrs3H0M9/7wuW/G6EMLZLQxpw+cg5wXUAvPU/gAHLQQ4GlKNXcIQvdctEXU/fbB5Lj/bLxMsAttU= 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 1655128623997406.8929549560363; Mon, 13 Jun 2022 06:57:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-217-v6mVos1PPkimTDtxFv3zLQ-1; Mon, 13 Jun 2022 09:56:55 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 226C785A581; Mon, 13 Jun 2022 13:56:52 +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 0EADE492C3B; Mon, 13 Jun 2022 13:56:52 +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 C8D411947062; Mon, 13 Jun 2022 13:56:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 760F6194705B for ; Mon, 13 Jun 2022 13:56:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 57540492CA6; Mon, 13 Jun 2022 13:56:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CB67492CA2 for ; Mon, 13 Jun 2022 13:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655128623; 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=wofBAGe3HP2jVohjgHN8mheXlpLj6wD7+cS4UrIx/X8=; b=YmoP6P/OPpcGMXJoCdlzYfNp7vYLl36DL6on+xxsSQSsTxQA+feEOnD/v8HwNdGfSYZhRW SCaVl4XWqKCh+th3/a0qo9lBvhbLlQq0p6EXazvB5TGxeD0tMR+3r3GEVw04SNHw9WbPeY qbComnTp7N75YEtUf6YlYLuHq+Xz/BY= X-MC-Unique: v6mVos1PPkimTDtxFv3zLQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/6] admin: Introduce virAdmConnectSetDaemonTimeout Date: Mon, 13 Jun 2022 15:56:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: 1655128624414100003 Content-Type: text/plain; charset="utf-8" Use of the admin APIs to modify logging temporarily has a rather serious deficiency when the daemon whose config is being changed is using auto-shutdown (default with socket-activated deployments) as the configuration is discarded if there is no client or VM/other object blocking auto shutdown. This API allows users to disable/postpone shutdown timeout so that the configuration doesn't change under their hands. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-admin.h | 4 ++++ src/admin/admin_protocol.x | 12 +++++++++- src/admin/admin_server_dispatch.c | 12 ++++++++++ src/admin/libvirt-admin.c | 34 +++++++++++++++++++++++++++++ src/admin/libvirt_admin_public.syms | 5 +++++ src/admin_protocol-structs | 5 +++++ 6 files changed, 71 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admi= n.h index 8533658932..ae4703f89b 100644 --- a/include/libvirt/libvirt-admin.h +++ b/include/libvirt/libvirt-admin.h @@ -480,6 +480,10 @@ int virAdmConnectSetLoggingFilters(virAdmConnectPtr co= nn, const char *filters, unsigned int flags); +int virAdmConnectSetDaemonTimeout(virAdmConnectPtr conn, + unsigned int timeout, + unsigned int flags); + # ifdef __cplusplus } # endif diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x index 7dc6724032..f3130efd2d 100644 --- a/src/admin/admin_protocol.x +++ b/src/admin/admin_protocol.x @@ -214,6 +214,11 @@ struct admin_connect_set_logging_filters_args { unsigned int flags; }; +struct admin_connect_set_daemon_timeout_args { + unsigned int timeout; + unsigned int flags; +}; + /* Define the program number, protocol version and procedure numbers here.= */ const ADMIN_PROGRAM =3D 0x06900690; const ADMIN_PROTOCOL_VERSION =3D 1; @@ -324,5 +329,10 @@ enum admin_procedure { /** * @generate: both */ - ADMIN_PROC_SERVER_UPDATE_TLS_FILES =3D 18 + ADMIN_PROC_SERVER_UPDATE_TLS_FILES =3D 18, + + /** + * @generate: both + */ + ADMIN_PROC_CONNECT_SET_DAEMON_TIMEOUT =3D 19 }; diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dis= patch.c index 893c7f1de2..8ab243c8eb 100644 --- a/src/admin/admin_server_dispatch.c +++ b/src/admin/admin_server_dispatch.c @@ -466,6 +466,18 @@ adminConnectSetLoggingFilters(virNetDaemon *dmn G_GNUC= _UNUSED, return virLogSetFilters(filters); } + +static int +adminConnectSetDaemonTimeout(virNetDaemon *dmn, + unsigned int timeout, + unsigned int flags) +{ + virCheckFlags(0, -1); + + return virNetDaemonAutoShutdown(dmn, timeout); +} + + static int adminDispatchConnectGetLoggingOutputs(virNetServer *server G_GNUC_UNUSED, virNetServerClient *client G_GNUC_UN= USED, diff --git a/src/admin/libvirt-admin.c b/src/admin/libvirt-admin.c index 5f64784a13..4b5d615e9d 100644 --- a/src/admin/libvirt-admin.c +++ b/src/admin/libvirt-admin.c @@ -1329,3 +1329,37 @@ virAdmConnectSetLoggingFilters(virAdmConnectPtr conn, virDispatchError(NULL); return -1; } + + +/** + * virAdmConnectSetDaemonTimeout: + * @conn: pointer to an active admin connection + * @timeout: timeout to set in seconds (0 disables timeout) + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Reconfigure the existing timeout of the daemon to @timeout. Setting tim= eout + * to 0 disables the daemon timeout. + * + * Returns 0 on success, -1 on error. + * + * Since: 8.5.0 + */ +int +virAdmConnectSetDaemonTimeout(virAdmConnectPtr conn, + unsigned int timeout, + unsigned int flags) +{ + int ret; + + VIR_DEBUG("conn=3D%p, timeout=3D%u, flags=3D0x%x", conn, timeout, flag= s); + + virResetLastError(); + virCheckAdmConnectReturn(conn, -1); + + if ((ret =3D remoteAdminConnectSetDaemonTimeout(conn, timeout, flags))= < 0) { + virDispatchError(NULL); + return -1; + } + + return ret; +} diff --git a/src/admin/libvirt_admin_public.syms b/src/admin/libvirt_admin_= public.syms index 8126973e5b..554269613c 100644 --- a/src/admin/libvirt_admin_public.syms +++ b/src/admin/libvirt_admin_public.syms @@ -48,3 +48,8 @@ LIBVIRT_ADMIN_3.0.0 { virAdmConnectSetLoggingOutputs; virAdmConnectSetLoggingFilters; } LIBVIRT_ADMIN_2.0.0; + +LIBVIRT_ADMIN_8.5.0 { + global: + virAdmConnectSetDaemonTimeout; +} LIBVIRT_ADMIN_3.0.0; diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs index 76c511babf..8caac59824 100644 --- a/src/admin_protocol-structs +++ b/src/admin_protocol-structs @@ -144,6 +144,10 @@ struct admin_connect_set_logging_filters_args { admin_string filters; u_int flags; }; +struct admin_connect_set_daemon_timeout_args { + u_int timeout; + u_int flags; +}; enum admin_procedure { ADMIN_PROC_CONNECT_OPEN =3D 1, ADMIN_PROC_CONNECT_CLOSE =3D 2, @@ -163,4 +167,5 @@ enum admin_procedure { ADMIN_PROC_CONNECT_SET_LOGGING_OUTPUTS =3D 16, ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS =3D 17, ADMIN_PROC_SERVER_UPDATE_TLS_FILES =3D 18, + ADMIN_PROC_CONNECT_SET_DAEMON_TIMEOUT =3D 19, }; --=20 2.36.1 From nobody Sat Feb 7 15:11: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=1655128621; cv=none; d=zohomail.com; s=zohoarc; b=bqC3uO/54StJpLDMzD7PACU1wbr04HwTAaRDEJT+dFLx8jGMwZClMRbfCo/xo1GJMG2Hs84FRpnAiJstVf1GyFZ179SM80MsyrLyN3LS8VmyWAFnS6vfq/bZk0Nt3ZXWR+SiclmgE6H7/jd1phg2fmK1jo4fFXXAkZYb0LI3jbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655128621; 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=ni3Habe16QVbGPTUDrxqmO4BWfc6/+jOSj1O0xS3wpo=; b=cV5sqPp7U+/Clf1QrUocDQm8tqDnLQR1cRJCy/rwxsMCUZaQANLr2MELfqaD2D7xmAROEcfrco/+f6wFN77JR9/8wjr2pjclYb4F4Oyj4duiN+PKd4kpo0MQtF2BIwONgT8sBSyIlWGaZDJo5kMfh7INPG9O6pxbcly6LRZ6oe8= 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 1655128621605644.7373817496106; Mon, 13 Jun 2022 06:57:01 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-464-ZcoZLq_FPySX7-SPCYcYnA-1; Mon, 13 Jun 2022 09:56:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A66C804181; Mon, 13 Jun 2022 13:56:53 +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 0455710725; Mon, 13 Jun 2022 13:56: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 AEB5C1947062; Mon, 13 Jun 2022 13:56:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9482B194705B for ; Mon, 13 Jun 2022 13:56:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 838F9492CA5; Mon, 13 Jun 2022 13:56:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC2C8492CA2 for ; Mon, 13 Jun 2022 13:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655128620; 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=ni3Habe16QVbGPTUDrxqmO4BWfc6/+jOSj1O0xS3wpo=; b=Oo/8qZp4dwllZKUf6B90jypZeyYPG00uzK/WvKsto2714jovcBpFiqE2EgqlKHn2oEnKGO 2jSmYY6+Mbfg6JPrS4v93fobrmviKFe8z0RKEi5En418fYwRAZiWSkKO7HkFT60jX/SKX3 jj2W2unhQ5Qx7m8Y6dcH/S12/T+dA+Q= X-MC-Unique: ZcoZLq_FPySX7-SPCYcYnA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/6] virt-admin: Introduce 'daemon-timeout' Date: Mon, 13 Jun 2022 15:56:32 +0200 Message-Id: <9f8d597c45a6af3338bdfd36f1aa44a89b56e52f.1655128518.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: 1655128622378100001 Content-Type: text/plain; charset="utf-8" Add a simple command to drive the new 'virAdmConnectSetDaemonTimeout' API. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- docs/manpages/virt-admin.rst | 12 ++++++++++ tools/virt-admin.c | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/docs/manpages/virt-admin.rst b/docs/manpages/virt-admin.rst index 30cfd24e73..479e27b2c2 100644 --- a/docs/manpages/virt-admin.rst +++ b/docs/manpages/virt-admin.rst @@ -313,6 +313,18 @@ To define multiple outputs at once they need to be del= imited by spaces: $ virt-admin daemon-log-outputs "4:stderr 2:syslog:" +daemon-timeout +-------------- + +**Syntax:** + +:: + + daemon-timeout --timeout NUM + +Sets the daemon timeout to the value of '--timeout' argument. Use ``--time= out 0`` +to disable auto-shutdown of the daemon. + SERVER COMMANDS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/tools/virt-admin.c b/tools/virt-admin.c index e010763e21..718df62854 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1072,6 +1072,45 @@ static const vshCmdInfo info_daemon_log_outputs[] = =3D { {.name =3D NULL} }; +static const vshCmdOptDef opts_daemon_timeout[] =3D { + {.name =3D "timeout", + .type =3D VSH_OT_INT, + .help =3D N_("number of seconds the daemon will run without any activ= e connection"), + .flags =3D VSH_OFLAG_REQ | VSH_OFLAG_REQ_OPT + }, + {.name =3D NULL} +}; + +static bool +cmdDaemonTimeout(vshControl *ctl, const vshCmd *cmd) +{ + vshAdmControl *priv =3D ctl->privData; + unsigned int timeout =3D 0; + + if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0) + return false; + + if (virAdmConnectSetDaemonTimeout(priv->conn, timeout, 0) < 0) + return false; + + return true; +} + + +/* -------------------------- + * Command daemon-timeout + * -------------------------- + */ +static const vshCmdInfo info_daemon_timeout[] =3D { + {.name =3D "help", + .data =3D N_("set the auto shutdown timeout of the daemon") + }, + {.name =3D "desc", + .data =3D N_("set the auto shutdown timeout of the daemon") + }, + {.name =3D NULL} +}; + static const vshCmdOptDef opts_daemon_log_outputs[] =3D { {.name =3D "outputs", .type =3D VSH_OT_STRING, @@ -1499,6 +1538,12 @@ static const vshCmdDef managementCmds[] =3D { .info =3D info_daemon_log_outputs, .flags =3D 0 }, + {.name =3D "daemon-timeout", + .handler =3D cmdDaemonTimeout, + .opts =3D opts_daemon_timeout, + .info =3D info_daemon_timeout, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.36.1 From nobody Sat Feb 7 15:11:02 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655128697; cv=none; d=zohomail.com; s=zohoarc; b=fnQLmATVAP6H81Tt4lb7IQ+TZkKLTCILB7sjZA+HQWnTYOOvWP2xDmZoPYhzgAFTM6G9xToVj0+7mPOF22Ui1p79FX73ULtjh76PUypGfO3Z+hK347wEwo1lerReKiwK1wAxABmHkf2k6TEZ6wKyFhlJpYNaLVenTHDDu9hRA4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655128697; 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=6JFG6sbi44qFEKJ3X9WZ7TtGEJGsSsddoOTzXmT9Odc=; b=BCKuJCK0qKAWNkevG3w6g06hnZPIBObFzhni7SKmv2fWxTTBnKpvbpqZexgDKoznzKYDTpYUt5PVVNGfThL+yaBUCbaltkhpIME9y0xfcLQig4lmdyBUtUDyTK+ny63PhgeZffoSAFTYYd2QgIvA7R2cfPUwzLaocGsjZYd0kn4= 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=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.129.124]) by mx.zohomail.com with SMTPS id 1655128697784777.7988221861974; Mon, 13 Jun 2022 06:58:17 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-agpdAnG1PFeRsqt7q-ULPA-1; Mon, 13 Jun 2022 09:56:58 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC84218E0045; Mon, 13 Jun 2022 13:56:55 +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 A8C4C492CA4; Mon, 13 Jun 2022 13:56:55 +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 1402D1947062; Mon, 13 Jun 2022 13:56:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A4FC1194705B for ; Mon, 13 Jun 2022 13:56:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9698F492CA5; Mon, 13 Jun 2022 13:56:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B966492CA2 for ; Mon, 13 Jun 2022 13:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655128696; 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=6JFG6sbi44qFEKJ3X9WZ7TtGEJGsSsddoOTzXmT9Odc=; b=GIpHTHgcIUgJuwK+FghWd9MCqRLMj89kmrWrDeOQUK+/5O4fyndEvsX66uKHaezx4Q4s63 /3bx+Q5ZlZRpEDk9g1XFAqwAPEMxVDHx6FZeKf2s4eIM6INfgzwFsc8VwK/xDJRYgRRlkt 9zQLEIROYYjeAfXR37YtslxKXD26ukw= X-MC-Unique: agpdAnG1PFeRsqt7q-ULPA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/6] kbase: debuglogs: Add a note about auto-shutdown of daemons Date: Mon, 13 Jun 2022 15:56:33 +0200 Message-Id: <6851376f9718b9c81f223d4d53c0822121fb6816.1655128518.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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: 1655128699145100001 Content-Type: text/plain; charset="utf-8" When using runtime setting of logging with 'virt-admin' it can be confusing that the settings are discarded when the shutdown timeout of a daemon is reached. Add a note about this behaviour along with a suggestion to use virt-admin to disable the behaviour if needed. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- docs/kbase/debuglogs.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/kbase/debuglogs.rst b/docs/kbase/debuglogs.rst index 83bc0e6ad7..68b9472a83 100644 --- a/docs/kbase/debuglogs.rst +++ b/docs/kbase/debuglogs.rst @@ -194,6 +194,26 @@ package manager provided by your distribution to insta= ll this package. guideline in the sections above in place of ``virt-admin`` in the examples below if needed. + +Timeout of the configured daemon +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Common deployments of libvirt start the libvirt daemons via socket activat= ion +and with automatic shutdown timeout of 120 seconds when no client or objec= t is +handled by the daemon. When a timeout is reached the daemon stops and all +settings done during runtime via ``virt-admin`` are discarded. The daemon = then +is re-started with another command. + +To prevent auto-shutdown of the daemon you can use the following command:: + + virt-admin daemon-timeout 0 + +The above is introduced in libvirt-8.5.0. + + +Adding filters and outputs +~~~~~~~~~~~~~~~~~~~~~~~~~~ + The following command allows to query the list of currently active log fil= ters: :: --=20 2.36.1