From: panzerzheng <panzerzh...@tencent.com>

When "/sys/power/state" does not contain "disk", the operating system
does not support hibernation. Executing "sudo systemctl hibernate" will
return an exit code of 1 with the stderr output: "Call to Hibernate failed:
Sleep verb 'hibernate' is not configured or configuration is not supported by 
kernel".

This patch adds handling for exit code 1 in the systemd_suspend function,
setting appropriate error messages when the kernel does not support standby.
It also adds local_err handling in the guest_suspend function to set
mode_supported to false.

Without these fixes, libvirt would hold the lock indefinitely.

Signed-off-by: panzerzheng <panzerzh...@tencent.com>
---
 qga/commands-linux.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/qga/commands-linux.c b/qga/commands-linux.c
index 9e8a934b9a..26229396c3 100644
--- a/qga/commands-linux.c
+++ b/qga/commands-linux.c
@@ -1300,6 +1300,12 @@ static void systemd_suspend(SuspendMode mode, Error 
**errp)
         return;
     }
 
+    if ((status == 1) && !local_err) {
+        error_setg(errp, "'systemctl %s' not suspend",
+                   systemctl_args[mode]);
+        return;
+    }
+
     if (local_err) {
         error_propagate(errp, local_err);
     } else {
@@ -1428,6 +1434,8 @@ static void guest_suspend(SuspendMode mode, Error **errp)
 
         if (!local_err) {
             return;
+        } else {
+            mode_supported = false;
         }
     }
 
-- 
2.43.7


Reply via email to