From nobody Mon Dec 15 09:41:38 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 174180044872186.72081188470565; Wed, 12 Mar 2025 10:27:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B46A41F83; Wed, 12 Mar 2025 13:27:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3DB161F52; Wed, 12 Mar 2025 13:26:18 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F329B1E62; Wed, 12 Mar 2025 13:26:12 -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 7830D1F63 for ; Wed, 12 Mar 2025 13:25:37 -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-534-ng9gZSb8NHOv68kH7b4drg-1; Wed, 12 Mar 2025 13:25:29 -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 E120218930C5 for ; Wed, 12 Mar 2025 17:18:07 +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 EF76C18001D4; Wed, 12 Mar 2025 17:18:06 +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=1741800337; 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=K9deI0AFJsAZCMmnuQN2LzyeECP74cBrhm5U4lP5KmE=; b=d6sY7P3thoHjyuzVLqHIakLUXIBqU7jd95ZpVdREA3jTuC7iAywoh0DSe7bzOXyvzX8XTs TzfBlwQZBUdqwV6pUZeShuK9ZyCxR83rsP9CLvHrKYYaVDfr8IUuJS3dwelT5DSGaqwemy Bw5Mf2MG0qbCHQTIcc/ZzSkzvkZqxyw= X-MC-Unique: ng9gZSb8NHOv68kH7b4drg-1 X-Mimecast-MFC-AGG-ID: ng9gZSb8NHOv68kH7b4drg_1741800328 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 02/22] remote: always invoke virStateStop for all daemons Date: Wed, 12 Mar 2025 17:17:42 +0000 Message-ID: <20250312171802.1854985-3-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: HDQV6rAKxiPqtsyZaFgof3BPoQf12JOfOynPbAvOpn8_1741800328 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3Y47W2HAEWXLZCLZAN7CDXGLDDXXICJK X-Message-ID-Hash: 3Y47W2HAEWXLZCLZAN7CDXGLDDXXICJK 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: 1741800450170019100 Content-Type: text/plain; charset="utf-8" Currently the virStateStop method is only wired up to run save for the unprivileged daemons, so there is no functional change. IOW, session exit, or host OS shutdown will trigger VM managed saved for QEMU session daemon, but not the system daemon. This changes the daemon code to always run virStateStop for all daemons. Instead the QEMU driver is responsible for skipping its own logic when running privileged...for now. This means that virStateStop will now be triggered by logind's PrepareForShutdown signal. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_driver.c | 3 ++- src/remote/remote_daemon.c | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 14b128d268..7e6ce5f69b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -949,7 +949,8 @@ qemuStateStop(void) .uri =3D cfg->uri, }; =20 - virDomainDriverAutoShutdown(&ascfg); + if (!qemu_driver->privileged) + virDomainDriverAutoShutdown(&ascfg); =20 return 0; } diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index d90355c0d2..2f6cef1828 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -628,30 +628,32 @@ static void daemonRunStateInit(void *opaque) virStateShutdownPrepare, virStateShutdownWait); =20 - /* Tie the non-privileged daemons to the session/shutdown lifecycle */ + /* Signal for VM shutdown when desktop session is terminated, in + * unprivileged daemons */ if (!virNetDaemonIsPrivileged(dmn)) { - if (virGDBusHasSessionBus()) { sessionBus =3D virGDBusGetSessionBus(); if (sessionBus !=3D NULL) g_dbus_connection_add_filter(sessionBus, handleSessionMessageFunc, dmn= , NULL); } + } =20 - if (virGDBusHasSystemBus()) { - systemBus =3D virGDBusGetSystemBus(); - if (systemBus !=3D NULL) - g_dbus_connection_signal_subscribe(systemBus, - "org.freedesktop.login1= ", - "org.freedesktop.login1= .Manager", - "PrepareForShutdown", - NULL, - NULL, - G_DBUS_SIGNAL_FLAGS_NON= E, - handleSystemMessageFunc, - dmn, - NULL); - } + if (virGDBusHasSystemBus()) { + /* Signal for VM shutdown when host OS shutdown is requested, in + * both privileged and unprivileged daemons */ + systemBus =3D virGDBusGetSystemBus(); + if (systemBus !=3D NULL) + g_dbus_connection_signal_subscribe(systemBus, + "org.freedesktop.login1", + "org.freedesktop.login1.Man= ager", + "PrepareForShutdown", + NULL, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + handleSystemMessageFunc, + dmn, + NULL); } =20 /* Only now accept clients from network */ --=20 2.48.1