[PATCH v2 02/22] remote: always invoke virStateStop for all daemons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 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 = cfg->uri,
     };
 
-    virDomainDriverAutoShutdown(&ascfg);
+    if (!qemu_driver->privileged)
+        virDomainDriverAutoShutdown(&ascfg);
 
     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);
 
-    /* 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 */
-- 
2.48.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux