]> git.ipfire.org Git - thirdparty/qemu.git/commit
qga: correctly write to /sys/power/state on linux
authorMichael Tokarev <mjt@tls.msk.ru>
Fri, 1 Aug 2025 11:53:14 +0000 (14:53 +0300)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 5 Aug 2025 19:03:08 +0000 (15:03 -0400)
commitb217d987a3c5c6e2473956723b396bc1ff0f5b2b
tree748d312a7f83788950def6d2ba2bcb6e58348e4b
parent8ee899e9b1a07657998279be0668e39851f3b68c
qga: correctly write to /sys/power/state on linux

Commit v9.0.0-343-g2048129625 introduced usage of
g_file_set_contents() function to write to /sys/power/state.
This function uses G_FILE_SET_CONTENTS_CONSISTENT flag to
g_file_set_contents_full(), which is implemented by creating
a temp file in the same directory and renaming it to the final
destination.  Which is not how sysfs works.

Here, there's not a big deal to do open/write/close - it becomes
almost the same as using g_file_set_contents[_full]().  But it
does not have surprises like this.

Also, since this is linux code, it should be ok to use %m in
the error reporting function.

Fixes: 2048129625 "qga/commands-posix: don't do fork()/exec() when suspending via sysfs"
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3057
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20250801115316.6845-1-mjt@tls.msk.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qga/commands-linux.c