From: "Daniel P. Berrange" <berrange@redhat.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>,
aliguori@us.ibm.com, qemu-devel <qemu-devel@nongnu.org>,
mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2] qemu-ga: Add the guest-suspend command
Date: Tue, 13 Dec 2011 23:13:23 +0000 [thread overview]
Message-ID: <20111213231323.GB4637@redhat.com> (raw)
In-Reply-To: <20111213162850.4cd135a3@doriath>
On Tue, Dec 13, 2011 at 04:28:50PM -0200, Luiz Capitulino wrote:
> It supports two modes: "hibernate" (which corresponds to S4) and
> "sleep" (which corresponds to S3). It will try to execute the
> pm-hibernate or pm-suspend scripts, if the scripts don't exist
> the command will try to suspend by directly writing to the
> "/sys/power/state" file.
>
> An interesting implementation detail is how to cleanup the child's
> status on termination, so that we don't create zombies. I've
> choosen to ignore the SIGCHLD signal. This will cause the kernel to
> automatically cleanup the child's status on its termination.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>
> I've tested this w/o any virtio driver, as they don't support S4 yet. For
> S4 it seems to work ok. I couldn't fully test S3 because we lack a way to
> resume from it, but by checking the logs it seems to work fine.
>
> changelog
> ---------
>
> v2
>
> o Rename the command to 'guest-suspend'
> o Add 'mode' parameter
> o Use pm-utils scripts
> o Cleanup child termination status
>
> qapi-schema-guest.json | 17 +++++++++++
> qemu-ga.c | 11 +++++++-
> qga/guest-agent-commands.c | 64 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 91 insertions(+), 1 deletions(-)
>
> diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json
> index 29989fe..656bde9 100644
> --- a/qapi-schema-guest.json
> +++ b/qapi-schema-guest.json
> @@ -219,3 +219,20 @@
> ##
> { 'command': 'guest-fsfreeze-thaw',
> 'returns': 'int' }
> +
> +##
> +# @guest-suspend
> +#
> +# Suspend guest execution by entering ACPI power state S3 or S4.
> +#
> +# @mode: 'hibernate' RAM content is saved in the disk and the guest is
> +# powered down (this corresponds to ACPI S4)
> +# 'sleep' execution is suspended but the RAM retains its contents
> +# (this corresponds to ACPI S3)
Standard pm-utils in Linux supports three ways to suspend these
days, suspend, hibernate & suspend-hybrid. libvirt supports
all 3 modes in our recently added API for suspending the physical
host, so I think we'll want to also have all 3 for suspending
guests too.
[quote pm-suspend(8)]
pm-suspend
During suspend most devices are shutdown, and
system state is saved in RAM. The system still
requires power in this state. Most modern systems
require 3 to 5 seconds to enter and leave suspend,
and most laptops can stay in suspend mode for 1 to
3 days before exhausting their battery.
pm-hibernate
During hibernate the system is fully powered off,
and system state is saved to disk. The system does
not require power, and can stay in hibernate mode
indefinitely. Most modern systems require 15 to 45
seconds to enter and leave hibernate, and entering
and leaving hibernate takes longer when you have
more memory.
pm-suspend-hybrid
Hybrid-suspend is the process where the system does
everything it needs to hibernate, but suspends
instead of shutting down. This means that your
computer can wake up quicker than for normal
hibernation if you do not run out of power, and you
can resume even if you run out of power. s2both(8)
is an hybrid-suspend implementation.
[/quote]
> diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c
> index a09c8ca..4799638 100644
> --- a/qga/guest-agent-commands.c
> +++ b/qga/guest-agent-commands.c
> @@ -574,6 +574,70 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
> }
> #endif
>
> +#define LINUX_PM_UTILS_PATH "/usr/sbin"
> +#define LINUX_SYS_STATE_FILE "/sys/power/state"
> +
> +void qmp_guest_suspend(const char *mode, Error **err)
> +{
> + int ret, fd = -1;
> + const char *pmutils_bin;
> + char pmutils_bin_path[PATH_MAX];
> +
> + if (strcmp(mode, "hibernate") == 0) {
> + pmutils_bin = "pm-hibernate";
> + } else if (strcmp(mode, "sleep") == 0) {
> + pmutils_bin = "pm-suspend";
Here you'd just add pm-suspend-hybrid too
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
next prev parent reply other threads:[~2011-12-13 23:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-13 18:28 [Qemu-devel] [PATCH v2] qemu-ga: Add the guest-suspend command Luiz Capitulino
2011-12-13 20:03 ` Michael Roth
2011-12-14 13:00 ` Luiz Capitulino
2011-12-14 15:54 ` Michael Roth
2011-12-14 16:38 ` Luiz Capitulino
2011-12-14 18:06 ` Michael Roth
2011-12-14 23:44 ` Luiz Capitulino
2011-12-14 18:17 ` Luiz Capitulino
2011-12-14 19:43 ` Michael Roth
2011-12-14 20:06 ` Luiz Capitulino
2011-12-14 20:56 ` Michael Roth
2011-12-14 21:14 ` Michael Roth
2011-12-14 23:56 ` Luiz Capitulino
2011-12-15 1:27 ` Michael Roth
2011-12-13 20:27 ` Michael Roth
2011-12-14 13:07 ` Luiz Capitulino
2011-12-14 15:50 ` Michael Roth
2011-12-13 23:13 ` Daniel P. Berrange [this message]
2011-12-14 13:08 ` Luiz Capitulino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111213231323.GB4637@redhat.com \
--to=berrange@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=amit.shah@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).