]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
remote: always invoke virStateStop for all daemons
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 17 Dec 2024 17:06:18 +0000 (17:06 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 20 Mar 2025 14:55:17 +0000 (14:55 +0000)
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 <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_driver.c
src/remote/remote_daemon.c

index 5f0f4561849e0b1a4106377dd08b47bfcefd58ac..8ccbd978289dd7c652586bb6e62689569f14bb65 100644 (file)
@@ -968,7 +968,8 @@ qemuStateStop(void)
         .uri = cfg->uri,
     };
 
-    virDomainDriverAutoShutdown(&ascfg);
+    if (!qemu_driver->privileged)
+        virDomainDriverAutoShutdown(&ascfg);
 
     return 0;
 }
index d90355c0d26aa39f51517284edf2361ac311b9a0..2f6cef1828ff37a18ae62c6a059063bbe5eee0b1 100644 (file)
@@ -628,30 +628,32 @@ static void daemonRunStateInit(void *opaque)
                                      virStateShutdownPrepare,
                                      virStateShutdownWait);
 
-    /* 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 = virGDBusGetSessionBus();
             if (sessionBus != NULL)
                 g_dbus_connection_add_filter(sessionBus,
                                              handleSessionMessageFunc, dmn, NULL);
         }
+    }
 
-        if (virGDBusHasSystemBus()) {
-            systemBus = virGDBusGetSystemBus();
-            if (systemBus != 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);
-        }
+    if (virGDBusHasSystemBus()) {
+        /* Signal for VM shutdown when host OS shutdown is requested, in
+         * both privileged and unprivileged daemons */
+        systemBus = virGDBusGetSystemBus();
+        if (systemBus != 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);
     }
 
     /* Only now accept clients from network */