On Mon, Aug 4, 2025 at 10:47 AM <zhengn...@gmail.com> wrote:

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

Is there any documentation that explains that exit code = 1 is an error?
If you look into systemd_supports_mode, you can see that exit code = 1 is
detected
as a supported mode.


> +        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;
>          }
>

This is very confusing. We check that the mode is supported, but after
running suspend,
we find that it is unsupported. I think we should fix systemd_supports_mode
instead.

Also, setting mode_supported = false does not change anything.
In the next step, we will check pmutils_supports_mode and
linux_sys_state_supports_mode,
and I think this check will pass, so we set mode_supported = true again.

Best Regards,
Kostiantyn Kostiuk.


>      }
>
> --
> 2.43.7
>
>

Reply via email to