From nobody Sun Feb 8 22:06:40 2026 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 1734434259728686.3901846719136; Tue, 17 Dec 2024 03:17:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 908231603; Tue, 17 Dec 2024 06:17:38 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 651C8160B; Tue, 17 Dec 2024 06:15:37 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9BCF915A0; Tue, 17 Dec 2024 06:15:30 -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 0573E15EE for ; Tue, 17 Dec 2024 06:15:19 -0500 (EST) 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-294-0g2KDKiHNJuXKOn6A0cqOQ-1; Tue, 17 Dec 2024 06:15:18 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 49489195608C for ; Tue, 17 Dec 2024 11:15:17 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.136]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 431B419560AD; Tue, 17 Dec 2024 11:15:16 +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=-1.7 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=1734434119; 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=pt5QEv8ippV1Zr1aqkRrLZFHEQ8MpTG9S4nCFcJ2aGM=; b=L72XKLwGVZ5Z6v3f7ttt5wCSdw2gAO6LLHjpSg1XoqJr+WmxIKYkBTYDS6NtypuKsrH2zR Dq2WjP112U2p6bDRv0tYLVxClcMa/fCyXqy9N5ww7F0S4O9NuOg7EQuboeTHeYLCKAtcaE fsmL3q2Gqujzk3FDD2HAJO06j27ZKak= X-MC-Unique: 0g2KDKiHNJuXKOn6A0cqOQ-1 X-Mimecast-MFC-AGG-ID: 0g2KDKiHNJuXKOn6A0cqOQ 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 3/3] rpc: remove logind support for virNetDaemon Date: Tue, 17 Dec 2024 11:15:09 +0000 Message-ID: <20241217111509.3779007-4-berrange@redhat.com> In-Reply-To: <20241217111509.3779007-1-berrange@redhat.com> References: <20241217111509.3779007-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: csrl_O96uf3HCVZdsNL2_fsbSrybs-AGv1LLXesG3_U_1734434117 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KPIQLMRWGCUF7UFQ5F7LGVFXI2KBZDQX X-Message-ID-Hash: KPIQLMRWGCUF7UFQ5F7LGVFXI2KBZDQX 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: 1734434260729116600 Content-Type: text/plain; charset="utf-8" The virNetDaemon code now only concerns itself with preventing auto shutdown of the local daemon. Logind is now handled by the new virInhibitor object, for QEMU, LXC and LibXL. This fixes two notable bugs * Running virtual networks would prevent system shutdown * Loaded ephemeral secrets would prevent system shutdown Fixes 9e3cc0ff5e81ed2056a6a528893fd2cb5609d70b Fixes 37800af9a400385801da6d73654249fdb51a93d8 Signed-off-by: Daniel P. Berrang=C3=A9 --- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/rpc/virnetdaemon.c | 78 ---------------------------------------- 4 files changed, 3 insertions(+), 81 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index eb293172f7..2c0cf75562 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -707,7 +707,7 @@ libxlStateInitialize(bool privileged, goto error; =20 libxl_driver->inhibitor =3D virInhibitorNew( - VIR_INHIBITOR_WHAT_NONE, + VIR_INHIBITOR_WHAT_SHUTDOWN, _("Libvirt Xen"), _("Xen virtual machines are running"), VIR_INHIBITOR_MODE_DELAY, diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 08516c8297..cc4b2a05d6 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1452,7 +1452,7 @@ lxcStateInitialize(bool privileged, goto cleanup; =20 lxc_driver->inhibitor =3D virInhibitorNew( - VIR_INHIBITOR_WHAT_NONE, + VIR_INHIBITOR_WHAT_SHUTDOWN, _("Libvirt LXC"), _("LXC containers are running"), VIR_INHIBITOR_MODE_DELAY, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c4cb9b2a9a..95a0e3a170 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -673,7 +673,7 @@ qemuStateInitialize(bool privileged, } =20 qemu_driver->inhibitor =3D virInhibitorNew( - VIR_INHIBITOR_WHAT_NONE, + VIR_INHIBITOR_WHAT_SHUTDOWN, _("Libvirt QEMU"), _("QEMU/KVM virtual machines are running"), VIR_INHIBITOR_MODE_DELAY, diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 9795418126..e4c6261536 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -31,7 +31,6 @@ #include "virutil.h" #include "virfile.h" #include "virnetserver.h" -#include "virgdbus.h" #include "virhash.h" #include "virprocess.h" #include "virsystemd.h" @@ -80,7 +79,6 @@ struct _virNetDaemon { int autoShutdownTimerID; bool autoShutdownTimerActive; size_t autoShutdownInhibitions; - int autoShutdownInhibitFd; }; =20 =20 @@ -109,7 +107,6 @@ virNetDaemonDispose(void *obj) virEventRemoveHandle(dmn->sigwatch); #endif /* !WIN32 */ =20 - VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd); g_free(dmn->stateStopThread); =20 g_clear_pointer(&dmn->servers, g_hash_table_unref); @@ -150,7 +147,6 @@ virNetDaemonNew(void) #endif /* !WIN32 */ =20 dmn->privileged =3D geteuid() =3D=3D 0; - dmn->autoShutdownInhibitFd =3D -1; =20 virProcessActivateMaxFiles(); =20 @@ -491,66 +487,6 @@ virNetDaemonAutoShutdown(virNetDaemon *dmn, } =20 =20 -#ifdef G_OS_UNIX -/* As per: https://www.freedesktop.org/wiki/Software/systemd/inhibit */ -static void -virNetDaemonCallInhibit(virNetDaemon *dmn, - const char *what, - const char *who, - const char *why, - const char *mode) -{ - g_autoptr(GVariant) reply =3D NULL; - g_autoptr(GUnixFDList) replyFD =3D NULL; - g_autoptr(GVariant) message =3D NULL; - GDBusConnection *systemBus; - int fd; - int rc; - - VIR_DEBUG("dmn=3D%p what=3D%s who=3D%s why=3D%s mode=3D%s", - dmn, NULLSTR(what), NULLSTR(who), NULLSTR(why), NULLSTR(mode= )); - - if (virSystemdHasLogind() < 0) - return; - - if (!(systemBus =3D virGDBusGetSystemBus())) - return; - - message =3D g_variant_new("(ssss)", what, who, why, mode); - - rc =3D virGDBusCallMethodWithFD(systemBus, - &reply, - G_VARIANT_TYPE("(h)"), - &replyFD, - NULL, - "org.freedesktop.login1", - "/org/freedesktop/login1", - "org.freedesktop.login1.Manager", - "Inhibit", - message, - NULL); - - if (rc < 0) - return; - - if (g_unix_fd_list_get_length(replyFD) <=3D 0) - return; - - fd =3D g_unix_fd_list_get(replyFD, 0, NULL); - if (fd < 0) - return; - - if (dmn->autoShutdownInhibitions) { - dmn->autoShutdownInhibitFd =3D fd; - VIR_DEBUG("Got inhibit FD %d", fd); - } else { - /* We stopped the last VM since we made the inhibit call */ - VIR_DEBUG("Closing inhibit FD %d", fd); - VIR_FORCE_CLOSE(fd); - } -} -#endif - void virNetDaemonAddShutdownInhibition(virNetDaemon *dmn) { @@ -559,15 +495,6 @@ virNetDaemonAddShutdownInhibition(virNetDaemon *dmn) dmn->autoShutdownInhibitions++; =20 VIR_DEBUG("dmn=3D%p inhibitions=3D%zu", dmn, dmn->autoShutdownInhibiti= ons); - -#ifdef G_OS_UNIX - if (dmn->autoShutdownInhibitions =3D=3D 1) - virNetDaemonCallInhibit(dmn, - "shutdown", - _("Libvirt"), - _("Virtual machines need to be saved"), - "delay"); -#endif } =20 =20 @@ -579,11 +506,6 @@ virNetDaemonRemoveShutdownInhibition(virNetDaemon *dmn) dmn->autoShutdownInhibitions--; =20 VIR_DEBUG("dmn=3D%p inhibitions=3D%zu", dmn, dmn->autoShutdownInhibiti= ons); - - if (dmn->autoShutdownInhibitions =3D=3D 0) { - VIR_DEBUG("Closing inhibit FD %d", dmn->autoShutdownInhibitFd); - VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd); - } } =20 =20 --=20 2.46.0