[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/14] qga: removing bios_supports_mode
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PULL 14/14] qga: removing bios_supports_mode |
Date: |
Tue, 3 Jul 2018 15:52:21 -0500 |
From: Daniel Henrique Barboza <address@hidden>
bios_support_mode verifies if the guest has support for a certain
suspend mode but it doesn't inform back which suspend tool
provides it. The caller, guest_suspend, executes all suspend
strategies in order again.
After adding systemd suspend support, bios_support_mode now will
verify for support for systemd, then pmutils, then Linux sys state
file. In a worst case scenario where both systemd and pmutils isn't
supported but Linux sys state is:
- bios_supports_mode will check for systemd, then pmutils, then
Linux sys state. It will tell guest_suspend that there is support,
but it will not tell who provides it;
- guest_suspend will try to execute (and fail) systemd suspend,
then pmutils suspend, to only then use the Linux sys suspend.
The time spent executing systemd and pmutils suspend was wasted
and could be avoided, but only bios_support_mode knew it but
didn't inform it back.
A quicker approach is to nuke bios_supports_mode and control
whether we found support at all with a bool flag inside
guest_suspend. guest_suspend will search for suspend support
and execute it as soon as possible. If the a given suspend
mechanism fails, continue to the next. If no suspend
support is found, the "not supported" message is still being
sent back to the user.
Signed-off-by: Daniel Henrique Barboza <address@hidden>
Signed-off-by: Michael Roth <address@hidden>
---
qga/commands-posix.c | 58 ++++++++++++++++------------------------------------
1 file changed, 18 insertions(+), 40 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index cdb825993f..233f78a406 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1712,64 +1712,42 @@ static void linux_sys_state_suspend(SuspendMode mode,
Error **errp)
}
-static void bios_supports_mode(SuspendMode mode, Error **errp)
-{
- Error *local_err = NULL;
- bool ret;
-
- ret = systemd_supports_mode(mode, &local_err);
- if (ret) {
- return;
- }
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
- ret = pmutils_supports_mode(mode, &local_err);
- if (ret) {
- return;
- }
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
- ret = linux_sys_state_supports_mode(mode, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
- if (!ret) {
- error_setg(errp,
- "the requested suspend mode is not supported by the guest");
- }
-}
-
static void guest_suspend(SuspendMode mode, Error **errp)
{
Error *local_err = NULL;
+ bool mode_supported = false;
- bios_supports_mode(mode, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
+ if (systemd_supports_mode(mode, &local_err)) {
+ mode_supported = true;
+ systemd_suspend(mode, &local_err);
}
- systemd_suspend(mode, &local_err);
if (!local_err) {
return;
}
error_free(local_err);
- pmutils_suspend(mode, &local_err);
+ if (pmutils_supports_mode(mode, &local_err)) {
+ mode_supported = true;
+ pmutils_suspend(mode, &local_err);
+ }
+
if (!local_err) {
return;
}
error_free(local_err);
- linux_sys_state_suspend(mode, &local_err);
- if (local_err) {
+ if (linux_sys_state_supports_mode(mode, &local_err)) {
+ mode_supported = true;
+ linux_sys_state_suspend(mode, &local_err);
+ }
+
+ if (!mode_supported) {
+ error_setg(errp,
+ "the requested suspend mode is not supported by the guest");
+ } else if (local_err) {
error_propagate(errp, local_err);
}
}
--
2.11.0
- [Qemu-devel] [PULL 02/14] qga: check bytes count read by guest-file-read, (continued)
- [Qemu-devel] [PULL 02/14] qga: check bytes count read by guest-file-read, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 10/14] qga: bios_supports_mode: decoupling pm-utils and sys logic, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 06/14] qga/schema: fix documentation for GuestOSInfo, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 13/14] qga: systemd hibernate/suspend/hybrid-sleep support, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 04/14] qga-win: add driver path usage to GuestFilesystemInfo, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 09/14] qga: refactoring qmp_guest_suspend_* functions, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 05/14] test-qga: add trivial tests for some commands, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 08/14] qemu-ga: make get-fsinfo work over pci bridges, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 11/14] qga: guest_suspend: decoupling pm-utils and sys logic, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 07/14] qga-win: Fixing msi upgrade disallow in WiX file, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 14/14] qga: removing bios_supports_mode,
Michael Roth <=
- [Qemu-devel] [PULL 01/14] qga: unset frozen state if no mount points are frozen, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 12/14] qga: removing switch statements, adding run_process_child, Michael Roth, 2018/07/03
- [Qemu-devel] [PULL 03/14] qga: add mountpoint usage info to GuestFilesystemInfo, Michael Roth, 2018/07/03
- Re: [Qemu-devel] [PULL 00/14] qga patch queue for soft-freeze, Peter Maydell, 2018/07/05