summary refs log tree commit diff stats
path: root/qga/commands-posix.c
diff options
context:
space:
mode:
authorMark Somerville <mark@qpok.net>2023-04-06 13:45:31 +0100
committerKonstantin Kostiuk <kkostiuk@redhat.com>2023-05-04 09:30:01 +0000
commit86dcb6ab9b603450eb6d896cdc95286de2c7d561 (patch)
tree7146b57ae92a95e208e19945c1a191a61307b0be /qga/commands-posix.c
parent8cc28cb16e696580ffa29cd5fee0d371303c805b (diff)
downloadfocaccia-qemu-86dcb6ab9b603450eb6d896cdc95286de2c7d561.tar.gz
focaccia-qemu-86dcb6ab9b603450eb6d896cdc95286de2c7d561.zip
qga: Fix suspend on Linux guests without systemd
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>
Diffstat (limited to 'qga/commands-posix.c')
-rw-r--r--qga/commands-posix.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 97754930c1..def857d773 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1922,10 +1922,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);
@@ -1934,10 +1934,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);