All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	wency@cn.fujitsu.com, hongyang.yang@easystack.cn,
	xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH RFC] libxc: Document xc_domain_resume
Date: Tue, 1 Mar 2016 00:16:44 +0000	[thread overview]
Message-ID: <56D4DF6C.6060900@citrix.com> (raw)
In-Reply-To: <1456775966-8475-1-git-send-email-konrad.wilk@oracle.com>

On 29/02/2016 19:59, Konrad Rzeszutek Wilk wrote:
> Document the save and suspend mechanism.
>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  tools/libxc/include/xenctrl.h | 52 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 150d727..9778947 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -565,6 +565,58 @@ int xc_domain_destroy(xc_interface *xch,
>   * This function resumes a suspended domain. The domain should have
>   * been previously suspended.
>   *
> + * Note that there are 'xc_domain_suspend' as suspending a domain
> + * is quite the endeavour. As such this long comment will describe the
> + * suspend and resume path.

I am not sure this second sentence is useful.

> + *
> + * For the purpose of this explanation there are three guests:
> + * PV (using hypercalls for privilgied operations), HVM
> + * (fully hardware virtualized guests using emulated devices for everything),
> + * and PVHVM (hardware virtualized guest with PV drivers).

PV aware with hardware virtualisation.  It is perfectly possible to be
"PV aware" without having blkfront and netfront drivers.  I realise this
is a grey area, but "PV drivers" does tend to imply the blk/net
protocols rather than the full "PV awareness".

> + *
> + * HVM guest are the simplest - they suspend via S3 and resume from
> + * S3. Upon resume they have to re-negotiate with the emulated devices.

And S4.

> + *
> + * PV and PVHVM communate via via hypercalls for suspend (and resume).
> + * For suspend the toolstack initiaties the process by writting an value in
> + * XenBus "control/shutdown" with the string "suspend".

I feel it is worth commenting about the stupidity of this protocol
whereby the ack mechanism is to clear the key, and the only reject/fail
mechanism is to leave the key unmodified and wait for the toolstack to
timeout.  (Similarly memory/target for ballooning.)

> + *
> + * The PV guest stashes anything it deems neccessary in 'struct start_info'
> + * in case of failure (PVHVM may ignore this) and calls the

What do you mean for the failure case here?

> + * SCHEDOP_shutdown::SHUTDOWN_suspend  hypercall (for PV as argument it
> + * passes the MFN to 'struct start_info').
> + *
> + * And then the guest is suspended.
> + *
> + * At this point the guest may be resumed on the same host under the same
> + * domain (checkpointing or suspending failed), or on a different host.

Slightly misleading.

The guest may be resumed in the same domain (in which case domid is the
same and all gubbins are still in place), or in a new domain; likely a
different domid, possibly a different host (but not impossible to switch
host and retain the same numeric domid) at which point all gubbins are lost.

> + *
> + * The checkpointing or notifying an guest that the suspend failed is by

"a guest"

> + * having the SCHEDOP_shutdown::SHUTDOWN_suspend hypercall return a non-zero
> + * value.

Do we have to document it as "suspend failed"?  In the case of a
checkpoint, it really isn't a failure.

> + *
> + * The PV and PVHVM resume path are similar. For PV it would be similar to bootup
> + * - figure out where the 'struct start_info' is (or if the suspend was
> + * cancelled aka checkpointed - reuse the saved values).

PV isn't similar to boot.

On boot, PV guests get start_info %rsi (or %esi) from the domain
builder.  In the case of suspend (failed or otherwise), start_info is in
%rdx (or %edx), (mutated as applicable by the safe/restore logic).

For HVM, there is no start info relevant for suspend/resume.

~Andrew

> + *
> + * From here on they differ depending whether the guest is PV or PVHVM
> + * in specifics but follow overall the same path:
> + *  - PV: Bringing up the vCPUS,
> + *  - PVHVM: Setup vector callback,
> + *  - Bring up vCPU runstates,
> + *  - Remap the grant tables if checkpointing or setup from scratch,
> + *
> + *
> + * If the resume was not checkpointing (or if suspend was succesful) we would
> + * setup the PV timers and the different PV events. Lastly the PV drivers
> + * re-negotiate with the backend.
> + *
> + * This function would return before the guest started resuming. That is
> + * the guest would be in non-running state and its vCPU context would be
> + * in the the SCHEDOP_shutdown::SHUTDOWN_suspend hypercall return path
> + * (for PV and PVHVM). For HVM it would be in would be in QEMU emulated
> + * BIOS handling S3 suspend.
> + *
>   * @parm xch a handle to an open hypervisor interface
>   * @parm domid the domain id to resume
>   * @parm fast use cooperative resume (guest must support this)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-03-01  0:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 19:59 [PATCH RFC] libxc: Document xc_domain_resume Konrad Rzeszutek Wilk
2016-03-01  0:16 ` Andrew Cooper [this message]
2016-03-01 13:43 ` Wei Liu

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=56D4DF6C.6060900@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=hongyang.yang@easystack.cn \
    --cc=ian.jackson@eu.citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=wency@cn.fujitsu.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.