]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
qga: Fix suspend on Linux guests without systemd
authorMark Somerville <mark@qpok.net>
Thu, 6 Apr 2023 12:45:31 +0000 (13:45 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 8 Jun 2023 10:30:40 +0000 (13:30 +0300)
Allow the Linux guest agent to attempt each of the suspend methods
(systemctl, pm-* and writing to /sys) in turn.

Prior to this guests without systemd failed to suspend due to
`guest_suspend` returning early regardless of the return value of
`systemd_supports_mode`.

Signed-off-by: Mark Somerville <mark@qpok.net>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
(cherry picked from commit 86dcb6ab9b603450eb6d896cdc95286de2c7d561)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
qga/commands-posix.c

index 079689d79a3af5c856d7d04212e78623ebf8b1ff..59e7154af4a155b353a86045a2e3e69eefbf84b7 100644 (file)
@@ -1918,10 +1918,10 @@ static void guest_suspend(SuspendMode mode, Error **errp)
     if (systemd_supports_mode(mode, &local_err)) {
         mode_supported = true;
         systemd_suspend(mode, &local_err);
-    }
 
-    if (!local_err) {
-        return;
+        if (!local_err) {
+            return;
+        }
     }
 
     error_free(local_err);
@@ -1930,10 +1930,10 @@ static void guest_suspend(SuspendMode mode, Error **errp)
     if (pmutils_supports_mode(mode, &local_err)) {
         mode_supported = true;
         pmutils_suspend(mode, &local_err);
-    }
 
-    if (!local_err) {
-        return;
+        if (!local_err) {
+            return;
+        }
     }
 
     error_free(local_err);