From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZgCi-0007M2-PQ for qemu-devel@nongnu.org; Sun, 11 Dec 2011 05:00:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RZgCh-00047s-Qj for qemu-devel@nongnu.org; Sun, 11 Dec 2011 05:00:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RZgCh-00047o-Jn for qemu-devel@nongnu.org; Sun, 11 Dec 2011 05:00:19 -0500 Message-ID: <4EE47F2C.6080406@redhat.com> Date: Sun, 11 Dec 2011 12:00:12 +0200 From: Dor Laor MIME-Version: 1.0 References: <20111208165258.17ab95f7@doriath> In-Reply-To: <20111208165258.17ab95f7@doriath> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] qemu-ga: Introduce guest-hibernate command Reply-To: dlaor@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Amit Shah , qemu-devel , mdroth@linux.vnet.ibm.com On 12/08/2011 08:52 PM, Luiz Capitulino wrote: > This is basically suspend to disk on a Linux guest. > > Signed-off-by: Luiz Capitulino > --- > > This is an RFC because I did it as simple as possible and I'm open to > suggestions... > > Now, while testing this or even "echo disk> /sys/power/state" I get several Beyond the previous comments about virtio s4 that Amit solved and pm-hibernate I think it will be nice to add suspend to ram (s3) option too. Currently qemu wakes up immediately after s3 but it can be fixed and it can pause the guest and wait to a keyboard event or monitor command. > funny results. Some times qemu just dies after printing that message: > > "Guest moved used index from 20151 to 1" > > Some times it doesn't die, but I'm unable to log into the guest: I type > username& password but the terminal kind of locks (the shell doesn't run). > > Some times it works... > > qapi-schema-guest.json | 11 +++++++++++ > qga/guest-agent-commands.c | 19 +++++++++++++++++++ > 2 files changed, 30 insertions(+), 0 deletions(-) > > diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json > index fde5971..2c5bbcf 100644 > --- a/qapi-schema-guest.json > +++ b/qapi-schema-guest.json > @@ -215,3 +215,14 @@ > ## > { 'command': 'guest-fsfreeze-thaw', > 'returns': 'int' } > + > +## > +# @guest-hibernate > +# > +# Save RAM contents to disk and powerdown the guest. > +# > +# Notes: This command doesn't return on success. > +# > +# Since: 1.1 > +## > +{ 'command': 'guest-hibernate' } > diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c > index 6da9904..9dd4060 100644 > --- a/qga/guest-agent-commands.c > +++ b/qga/guest-agent-commands.c > @@ -550,6 +550,25 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err) > } > #endif > > +#define LINUX_SYS_STATE_FILE "/sys/power/state" > + > +void qmp_guest_hibernate(Error **err) > +{ > + int fd; > + > + fd = open(LINUX_SYS_STATE_FILE, O_WRONLY); > + if (fd< 0) { > + error_set(err, QERR_OPEN_FILE_FAILED, LINUX_SYS_STATE_FILE); > + return; > + } > + > + if (write(fd, "disk", 4)< 0) { > + error_set(err, QERR_UNDEFINED_ERROR); > + } > + > + close(fd); > +} > + > /* register init/cleanup routines for stateful command groups */ > void ga_command_state_init(GAState *s, GACommandState *cs) > {