From nobody Mon Dec 15 09:42:40 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 17418001530741.455958607847947; Wed, 12 Mar 2025 10:22:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6627A1C58; Wed, 12 Mar 2025 13:22:32 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 99BA41E9F; Wed, 12 Mar 2025 13:18:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A8E3F1AED; Wed, 12 Mar 2025 13:18:53 -0400 (EDT) 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 897B11AED for ; Wed, 12 Mar 2025 13:18:29 -0400 (EDT) Received: from mx-prod-mc-01.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-617-39KGxMtyOxiwU7WlpeCmug-1; Wed, 12 Mar 2025 13:18:28 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 44DD31956060 for ; Wed, 12 Mar 2025 17:18:27 +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 201F6180174E; Wed, 12 Mar 2025 17:18:25 +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_H5,RCVD_IN_MSPIKE_WL,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=1741799909; 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=8M2u+455nYDPyFIlB2IbivvQZywsFNzZe67HY5bJni4=; b=XRZbwRKQxHaqmHA/vFxXqp9bGs6KbZn5X/79V/LBjrUIw/TnoQ8mXSxF1Cpm73l9ojJk92 ZbLocv2kyfxyJY5qiRVSg9b2boH0lEGxy6DYjLzgfR3K0zqsjzHe1+mf5k0ytgfe9sPXKW HqieiDsuyahIftYulYCE9cXVJZus6fc= X-MC-Unique: 39KGxMtyOxiwU7WlpeCmug-1 X-Mimecast-MFC-AGG-ID: 39KGxMtyOxiwU7WlpeCmug_1741799907 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 14/22] qemu: add config to control if auto-shutdown VMs are restored Date: Wed, 12 Mar 2025 17:17:54 +0000 Message-ID: <20250312171802.1854985-15-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: oEfTZ9_tRee8W_oM4-6GznU1qWL_yekL7jvar4MFf3E_1741799907 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QMTM3WPC4J3IBAZW5OFQKACZOBFJ7TON X-Message-ID-Hash: QMTM3WPC4J3IBAZW5OFQKACZOBFJ7TON 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: 1741800154631019000 Content-Type: text/plain; charset="utf-8" If shutting down running VMs at host shutdown, it can be useful to automatically start them again on next boot. This adds a config parameter 'auto_shutdown_restore', which defaults to enabled, which leverages the autostart once feature. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf.in | 4 ++++ src/qemu/qemu_conf.c | 3 +++ src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 1 + src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 11 insertions(+) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 9fa6398d8d..ee39da73b9 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -102,6 +102,7 @@ module Libvirtd_qemu =3D | str_entry "auto_shutdown_try_shutdown" | str_entry "auto_shutdown_poweroff" | int_entry "auto_shutdown_wait" + | bool_entry "auto_shutdown_restore" | bool_entry "auto_save_bypass_cache" =20 let process_entry =3D str_entry "hugetlbfs_mount" diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 5643e849ad..794b8cf31f 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -689,6 +689,10 @@ # is currently 30 secs) #auto_shutdown_wait =3D 30 =20 +# Whether VMs that are automatically powered off or saved during +# host shutdown, should be set to restore on next boot +#auto_shutdown_restore =3D 1 + # When a domain is configured to be auto-saved on shutdown, enabling # this flag has the same effect as using the VIR_DOMAIN_SAVE_BYPASS_CACHE # flag with the virDomainManagedSave API. That is, the system will diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 6161a3c8d6..fa6a9941b4 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -318,6 +318,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privil= eged, cfg->autoShutdownTryShutdown =3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_S= COPE_ALL; cfg->autoShutdownPoweroff =3D VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOP= E_ALL; } + cfg->autoShutdownRestore =3D true; =20 return g_steal_pointer(&cfg); } @@ -732,6 +733,8 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *c= fg, if (virConfGetValueUInt(conf, "auto_shutdown_wait", &cfg->autoShutdownWait) < 0) return -1; + if (virConfGetValueBool(conf, "auto_shutdown_restore", &cfg->autoShutd= ownRestore) < 0) + return -1; if (virConfGetValueBool(conf, "auto_save_bypass_cache", &cfg->autoSaveBypassCache) < 0) return -1; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 06c917ba3e..d064c7bb9c 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -206,6 +206,7 @@ struct _virQEMUDriverConfig { virDomainDriverAutoShutdownScope autoShutdownTryShutdown; virDomainDriverAutoShutdownScope autoShutdownPoweroff; unsigned int autoShutdownWait; + bool autoShutdownRestore; bool autoSaveBypassCache; =20 char *lockManagerName; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3b74a98685..ccac2a1259 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -952,6 +952,7 @@ qemuStateStop(void) .poweroff =3D cfg->autoShutdownPoweroff, .waitShutdownSecs =3D cfg->autoShutdownWait, .saveBypassCache =3D cfg->autoSaveBypassCache, + .autoRestore =3D cfg->autoShutdownRestore, }; =20 virDomainDriverAutoShutdown(&ascfg); diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index 65d0c20fe1..922cb35db7 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -80,6 +80,7 @@ module Test_libvirtd_qemu =3D { "auto_shutdown_try_shutdown" =3D "all" } { "auto_shutdown_poweroff" =3D "all" } { "auto_shutdown_wait" =3D "30" } +{ "auto_shutdown_restore" =3D "1" } { "auto_save_bypass_cache" =3D "0" } { "hugetlbfs_mount" =3D "/dev/hugepages" } { "bridge_helper" =3D "qemu-bridge-helper" } --=20 2.48.1