From nobody Mon Dec 15 09:41:46 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 1741800519817360.34323528309324; Wed, 12 Mar 2025 10:28:39 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4070F1F72; Wed, 12 Mar 2025 13:28:39 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D7D4E1F71; Wed, 12 Mar 2025 13:26:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 40F9C1C39; Wed, 12 Mar 2025 13:26:23 -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 CC5B71CD7 for ; Wed, 12 Mar 2025 13:25:45 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-ve267aEaOHmACdjkmk1HsQ-1; Wed, 12 Mar 2025 13:25:44 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0001718908DF for ; Wed, 12 Mar 2025 17:18:23 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.57]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E492C1801757; Wed, 12 Mar 2025 17:18: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.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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=1741800345; 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=j07yMj1bp/Ln3ipZHzuX7MllVXSmSdnBpaSAJ4G89wY=; b=QmAeNDPA0ErGZcVTfZqG9mB9aUJ+NmwOsaKmOf9rB1CyZOqK3MrMUrRGV86JRcotKXOifU PYEgACeP+i46OTtUSacFbErDpOJXq3WSXMZSfMsylyO95NyplakV95cLPt6+zZIe/U5kp+ Lnqgu7ddTl5F4pH3gpsH+xj5Y6CSoKo= X-MC-Unique: ve267aEaOHmACdjkmk1HsQ-1 X-Mimecast-MFC-AGG-ID: ve267aEaOHmACdjkmk1HsQ_1741800343 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 v2 12/22] hypervisor: wire up support for auto restore of running domains Date: Wed, 12 Mar 2025 17:17:52 +0000 Message-ID: <20250312171802.1854985-13-berrange@redhat.com> In-Reply-To: <20250312171802.1854985-1-berrange@redhat.com> References: <20250312171802.1854985-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sJe-_G-RKMg8gX7mXACLrjBsWv9s1lJ6i8DnvBYL8OM_1741800343 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VWKJQFRFTS3XNF2CWMUZNVUWNGIUYV5C X-Message-ID-Hash: VWKJQFRFTS3XNF2CWMUZNVUWNGIUYV5C 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: 1741800520151019000 Content-Type: text/plain; charset="utf-8" When performing auto-shutdown of running domains, there is now the option to mark them as "autostart once", so that their state is restored on next boot. This applies on top of the traditional autostart flag. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrang=C3=A9 --- src/hypervisor/domain_driver.c | 19 +++++++++++++++++-- src/hypervisor/domain_driver.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index bfba435ee0..1105d36388 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -738,12 +738,12 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdo= wnConfig *cfg) virDomainPtr *domains =3D NULL; g_autofree bool *transient =3D NULL; =20 - VIR_DEBUG("Run autoshutdown uri=3D%s trySave=3D%s tryShutdown=3D%s pow= eroff=3D%s waitShutdownSecs=3D%u saveBypassCache=3D%d", + VIR_DEBUG("Run autoshutdown uri=3D%s trySave=3D%s tryShutdown=3D%s pow= eroff=3D%s waitShutdownSecs=3D%u saveBypassCache=3D%d autoRestore=3D%d", cfg->uri, virDomainDriverAutoShutdownScopeTypeToString(cfg->trySave), virDomainDriverAutoShutdownScopeTypeToString(cfg->tryShutdow= n), virDomainDriverAutoShutdownScopeTypeToString(cfg->poweroff), - cfg->waitShutdownSecs, cfg->saveBypassCache); + cfg->waitShutdownSecs, cfg->saveBypassCache, cfg->autoRestor= e); =20 /* * Ideally guests will shutdown in a few seconds, but it would @@ -788,6 +788,21 @@ virDomainDriverAutoShutdown(virDomainDriverAutoShutdow= nConfig *cfg) for (i =3D 0; i < numDomains; i++) { if (virDomainIsPersistent(domains[i]) =3D=3D 0) transient[i] =3D true; + + if (cfg->autoRestore) { + if (transient[i]) { + VIR_DEBUG("Cannot auto-restore transient VM %s", + virDomainGetName(domains[i])); + } else { + VIR_DEBUG("Mark %s for autostart on next boot", + virDomainGetName(domains[i])); + if (virDomainSetAutostartOnce(domains[i], 1) < 0) { + VIR_WARN("Unable to mark domain '%s' for auto restore:= %s", + virDomainGetName(domains[i]), + virGetLastErrorMessage()); + } + } + } } =20 if (cfg->trySave !=3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE) { diff --git a/src/hypervisor/domain_driver.h b/src/hypervisor/domain_driver.h index fae316ee2d..d90466b942 100644 --- a/src/hypervisor/domain_driver.h +++ b/src/hypervisor/domain_driver.h @@ -113,6 +113,7 @@ typedef struct _virDomainDriverAutoShutdownConfig { * If 0 a default is used (currently 30= secs) */ bool saveBypassCache; + bool autoRestore; } virDomainDriverAutoShutdownConfig; =20 void virDomainDriverAutoShutdown(virDomainDriverAutoShutdownConfig *cfg); --=20 2.48.1