From nobody Tue Jan 21 07:22:21 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 173636566589334.8693397218542; Wed, 8 Jan 2025 11:47:45 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E26891509; Wed, 8 Jan 2025 14:47:44 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 238FA149A; Wed, 8 Jan 2025 14:43:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 86A2B1381; Wed, 8 Jan 2025 14:43:36 -0500 (EST) 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 9515E1381 for ; Wed, 8 Jan 2025 14:43:14 -0500 (EST) Received: from mx-prod-mc-05.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-18-GX2CeLkhNiOnuHmzHhhgbw-1; Wed, 08 Jan 2025 14:43:12 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8AFAB19560A1 for ; Wed, 8 Jan 2025 19:43:11 +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 B1215300018D; Wed, 8 Jan 2025 19:43:10 +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_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=1736365394; 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=g7ChhWyATd1vTshDnrAtLYAqQ31Vf1hHcS6CDXIB0HU=; b=iMLvvGuvTNSzr7yaKZbxDcM/O3vnRLBZipVhzPM8CjSoCOhh72Wlw/ckqAKTXDdBk0XY8n xssI8TXdHjoAJHEkBRIElfkmKjSRvCcektncK69bSrW9hioDplKYg1go7b1Dr2VIuye0HN 2RT0Cfl66imE9wcY3/Uba229/e9RQrw= X-MC-Unique: GX2CeLkhNiOnuHmzHhhgbw-1 X-Mimecast-MFC-AGG-ID: GX2CeLkhNiOnuHmzHhhgbw 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 08/26] remote: always invoke virStateStop for all daemons Date: Wed, 8 Jan 2025 19:42:41 +0000 Message-ID: <20250108194259.1171990-9-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: 1OOA3DmVYQQvV_8KcfgyZFhHTsKt9AE4PQkuHY7J9DE_1736365391 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GK2TZ6LE4TXDPLQKEHFPLWRFA5RZX7RT X-Message-ID-Hash: GK2TZ6LE4TXDPLQKEHFPLWRFA5RZX7RT 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: 1736365727958116600 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. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_driver.c | 3 ++- src/remote/remote_daemon.c | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8c16566ce8..103369ac93 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 d44a365000..c4b930cb70 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -628,27 +628,29 @@ 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)) { - sessionBus =3D virGDBusGetSessionBus(); if (sessionBus !=3D NULL) g_dbus_connection_add_filter(sessionBus, handleSessionMessageFunc, dmn, NU= LL); + } =20 - 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, + /* 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.Manager= ", + "PrepareForShutdown", + NULL, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + handleSystemMessageFunc, dmn, NULL); - } =20 /* Only now accept clients from network */ virNetDaemonUpdateServices(dmn, true); --=20 2.47.1