From nobody Sun Dec 14 06:36:35 2025 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=1751547169; cv=none; d=zohomail.com; s=zohoarc; b=S9XXF3NIPAqkafg1LBIHImihUNZOZpCFZ+SzO7Xx5ffoiaciuUQBfv05ipP2htNJ6/F+ak8yEr2F5/OHhJKtvl/1OYXYTWPv91Of55Aba0T4Ug2TUNCCnY7sWUM8JU8Hb/CuaSvzPQf9ni1XyFraLvkmFYwGJNGhbYjgqWX1Cl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751547169; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post: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=eNbdeLp419aVuOpWLR4uKlHuHRwZLk9qmQYwCRpVcKE=; b=LeESVFLZOmSxV+vPBK1RbHw5iJUdhNWBAcOovjTN2tePMKGVNwx6MfmmQNoIH5icUvFwEHNfQ8Iv3KDXWBwIxXnJAv+dK8tMuhzTQwe0PVkkizIbbzg8Y08FFslMwd6RWc1yoBBXyvEvZg60BB05oF5lmTPgC1k1Fmhyx/He3Vs= 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 1751547169289524.9615145830436; Thu, 3 Jul 2025 05:52:49 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 34F4212AC; Thu, 3 Jul 2025 08:52:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 31A781398; Thu, 3 Jul 2025 08:50:58 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 08209CD0; Thu, 3 Jul 2025 08:50:53 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C40F21238 for ; Thu, 3 Jul 2025 08:50:43 -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-692-Zz8Yg7CVNguuH95ehbIYWQ-1; Thu, 03 Jul 2025 08:50:42 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 6991D18DA380 for ; Thu, 3 Jul 2025 12:50:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.5]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9EBA6195608F for ; Thu, 3 Jul 2025 12:50:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751547043; 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=+DnNKuXhBI+GQJ2Qw9XpKWSZ9kPihermU5p+YkkOjlc=; b=b99knwKdsYOr+lki+Xs6/qOetS1R30QZjJCCQwqbpR/0c8s6gvk+P9MIfZjyPJu3iIbXAy kcUu9t+mAXuKtKAH2BIj37mFCAimJoAjQf65CaFyDpg2VoGqxzXakaiED0P6RYtCLdUugN uQSceXIEk8zKULIECf1u8ZEr7uqA3DU= X-MC-Unique: Zz8Yg7CVNguuH95ehbIYWQ-1 X-Mimecast-MFC-AGG-ID: Zz8Yg7CVNguuH95ehbIYWQ_1751547041 To: devel@lists.libvirt.org Subject: [PATCH 04/10] hypervisor: domain: Extract logic for auto shutdown to virDomainDriverAutoShutdownActive Date: Thu, 3 Jul 2025 14:50:27 +0200 Message-ID: <11355abddee1ed9ea971cbfcdf4443b8a3f018ba.1751546915.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: pNU87ey-J3CE8rqvLnCcPXB6-11gmEbnQhtbelZrB84_1751547041 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5UPZWCWWCIO5X7FSK6HC3EMLD4MUILZH X-Message-ID-Hash: 5UPZWCWWCIO5X7FSK6HC3EMLD4MUILZH X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1751547170742116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Extract the checker that determines whether the daemon auto shutdown functionality is active to a separate helper 'virDomainDriverAutoShutdownActive'. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/hypervisor/domain_driver.c | 13 ++++++++++--- src/hypervisor/domain_driver.h | 1 + src/libvirt_private.syms | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 62bbe176ae..353b8875ec 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -729,6 +729,15 @@ virDomainDriverAutoStart(virDomainObjList *domains, } +bool +virDomainDriverAutoShutdownActive(virDomainDriverAutoShutdownConfig *cfg) +{ + return cfg->trySave !=3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE || + cfg->tryShutdown !=3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE || + cfg->poweroff !=3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE; +} + + void virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg) { @@ -773,9 +782,7 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdown= Config *cfg) } /* Short-circuit if all actions are disabled */ - if (cfg->trySave =3D=3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE && - cfg->tryShutdown =3D=3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE= && - cfg->poweroff =3D=3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE) + if (!virDomainDriverAutoShutdownActive(cfg)) return; if (!(conn =3D virConnectOpen(cfg->uri))) diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index d90466b942..af1c4eaed6 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -116,4 +116,5 @@ typedef struct _virDomainDriverAutoShutdownConfig { bool autoRestore; } virDomainDriverAutoShutdownConfig; +bool virDomainDriverAutoShutdownActive(virDomainDriverAutoShutdownConfig *= cfg); void virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8f1489ecc8..1b9be478e4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1658,6 +1658,7 @@ virDomainCgroupSetupVcpuBW; # hypervisor/domain_driver.h virDomainDriverAddIOThreadCheck; virDomainDriverAutoShutdown; +virDomainDriverAutoShutdownActive; virDomainDriverAutoShutdownScopeTypeFromString; virDomainDriverAutoShutdownScopeTypeToString; virDomainDriverAutoStart; --=20 2.49.0