[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] qemu-ga: Add the guest-suspend command
From: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [PATCH v2] qemu-ga: Add the guest-suspend command |
Date: |
Wed, 14 Dec 2011 11:08:05 -0200 |
On Tue, 13 Dec 2011 23:13:23 +0000
"Daniel P. Berrange" <address@hidden> wrote:
> 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 <address@hidden>
> > ---
> >
> > 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.
Ok.
>
> [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
Re: [Qemu-devel] [PATCH v2] qemu-ga: Add the guest-suspend command, Michael Roth, 2011/12/13
Re: [Qemu-devel] [PATCH v2] qemu-ga: Add the guest-suspend command, Daniel P. Berrange, 2011/12/13
- Re: [Qemu-devel] [PATCH v2] qemu-ga: Add the guest-suspend command,
Luiz Capitulino <=