diff mbox series

[PULL,6/6] qga: Fix suspend on Linux guests without systemd

Message ID 20230504095657.239048-7-kkostiuk@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,1/6] qga/linux: add usb support to guest-get-fsinfo | expand

Commit Message

Konstantin Kostiuk May 4, 2023, 9:56 a.m. UTC
From: Mark Somerville <mark@qpok.net>

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>
---
 qga/commands-posix.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

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);