From nobody Tue Jan 21 07:20:45 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736365893471917.6776678818803; Wed, 8 Jan 2025 11:51:33 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A65B138B; Wed, 8 Jan 2025 14:51:32 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 650EE14B0; Wed, 8 Jan 2025 14:44:06 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 58E261223; Wed, 8 Jan 2025 14:43:51 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 325DF1423 for ; Wed, 8 Jan 2025 14:43:25 -0500 (EST) Received: from mx-prod-mc-04.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-687-UXg27X5MP5m6ISAGbRIRHA-1; Wed, 08 Jan 2025 14:43:23 -0500 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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 95F951944B2E for ; Wed, 8 Jan 2025 19:43:22 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.103]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C01023000199; Wed, 8 Jan 2025 19:43:21 +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=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736365404; h=from:from: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; bh=pIzvw8w9TmVCORsgLsVr/a2Fy/g7zoBPs1NFAQsI5tc=; b=cBurkYMbwNelmkTmIznEI9wguhP88mlXMMcKMMeXAZniLof/yLoKkEdHkomYuvvxUT85po 17zVXkdXCaG+uwkk5/Cv2/WolaLHrxX8wazduUpgun4hImPIyF/3llIz/ghNAcMzEMbw6g HYt/68j9qtvRrw7Pn3l13PJiSckaPnY= X-MC-Unique: UXg27X5MP5m6ISAGbRIRHA-1 X-Mimecast-MFC-AGG-ID: UXg27X5MP5m6ISAGbRIRHA From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 17/26] conf: implement support for autostart once feature Date: Wed, 8 Jan 2025 19:42:50 +0000 Message-ID: <20250108194259.1171990-18-berrange@redhat.com> In-Reply-To: <20250108194259.1171990-1-berrange@redhat.com> References: <20250108194259.1171990-1-berrange@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: baQfBpg5iKZt1O9-TQ57JrS8ScBrQlLNZu_ad5DaXhU_1736365402 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Y6ZY5HKI25JOWUJVNN7D2BHVRJDLBYV6 X-Message-ID-Hash: Y6ZY5HKI25JOWUJVNN7D2BHVRJDLBYV6 X-MailFrom: berrange@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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736365895148116600 Content-Type: text/plain; charset="utf-8" This is maintained in the same way as the autostart flag, using a symlink. The difference is that instead of '.xml', the symlink suffix is '.xml.once'. The link is also deleted immediately after it has been read. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 6 +++++- src/conf/domain_conf.h | 1 + src/conf/virdomainobjlist.c | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index af88d0bcfd..4a794d1f71 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29083,13 +29083,17 @@ virDomainDeleteConfig(const char *configDir, { g_autofree char *configFile =3D NULL; g_autofree char *autostartLink =3D NULL; + g_autofree char *autostartOnceLink =3D NULL; =20 configFile =3D virDomainConfigFile(configDir, dom->def->name); autostartLink =3D virDomainConfigFile(autostartDir, dom->def->name); + autostartOnceLink =3D g_strdup_printf("%s.once", autostartLink); =20 - /* Not fatal if this doesn't work */ + /* Not fatal if these don't work */ unlink(autostartLink); + unlink(autostartOnceLink); dom->autostart =3D 0; + dom->autostartOnce =3D 0; =20 if (unlink(configFile) < 0 && errno !=3D ENOENT) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9f7c28343f..f30143e704 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3282,6 +3282,7 @@ struct _virDomainObj { virDomainStateReason state; =20 unsigned int autostart : 1; + unsigned int autostartOnce : 1; unsigned int persistent : 1; unsigned int updated : 1; unsigned int removing : 1; diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 72207450c5..ba2f9f544d 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -487,9 +487,10 @@ virDomainObjListLoadConfig(virDomainObjList *doms, { g_autofree char *configFile =3D NULL; g_autofree char *autostartLink =3D NULL; + g_autofree char *autostartOnceLink =3D NULL; g_autoptr(virDomainDef) def =3D NULL; virDomainObj *dom; - int autostart; + int autostart, autostartOnce; g_autoptr(virDomainDef) oldDef =3D NULL; =20 configFile =3D virDomainConfigFile(configDir, name); @@ -500,13 +501,17 @@ virDomainObjListLoadConfig(virDomainObjList *doms, return NULL; =20 autostartLink =3D virDomainConfigFile(autostartDir, name); + autostartOnceLink =3D g_strdup_printf("%s.once", autostartLink); =20 autostart =3D virFileLinkPointsTo(autostartLink, configFile); + autostartOnce =3D virFileLinkPointsTo(autostartOnceLink, configFile); + unlink(autostartOnceLink); =20 if (!(dom =3D virDomainObjListAddLocked(doms, &def, xmlopt, 0, &oldDef= ))) return NULL; =20 dom->autostart =3D autostart; + dom->autostartOnce =3D autostartOnce; =20 if (notify) (*notify)(dom, oldDef =3D=3D NULL, opaque); --=20 2.47.1