qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qga: Fix error handling in system suspend mode causing libvirt to hold lock indefinitely
@ 2025-08-04  7:46 zhengnici
  2025-08-04  8:18 ` Kostiantyn Kostiuk
  0 siblings, 1 reply; 3+ messages in thread
From: zhengnici @ 2025-08-04  7:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: michael.roth, kkostiuk, panzerzheng

From: panzerzheng <panzerzheng@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 <panzerzheng@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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-04 13:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04  7:46 [PATCH] qga: Fix error handling in system suspend mode causing libvirt to hold lock indefinitely zhengnici
2025-08-04  8:18 ` Kostiantyn Kostiuk
2025-08-04  9:54   ` nici zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).