libxc: Document xc_domain_resume
RFC PATCH 1/1 libxc: Document xc_domain_resume
Document the save and suspend mechanism.
--- tools/libxc/include/xenctrl.h | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
tools/libxc/include/xenctrl.h +52 -0
@@ -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. +* +* 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). +* +* HVM guest are the simplest - they suspend via S3 and resume from +* S3. Upon resume they have to re-negotiate with the emulated devices. +* +* 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". +* +* The PV guest stashes anything it deems neccessary in 'struct start_info' +* in case of failure (PVHVM may ignore this) and calls the +* 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. +* +* The checkpointing or notifying an guest that the suspend failed is by +* having the SCHEDOP_shutdown::SHUTDOWN_suspend hypercall return a non-zero +* value. +* +* 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). +* +* 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)
Signature · 7 lines
2.4.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 12 lines · Konrad Rzeszutek Wilk
Document the save and suspend mechanism.
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- tools/libxc/include/xenctrl.h | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)tools/libxc/include/xenctrl.h +0
-0
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 570
Quoted 6 lines
tools/libxc/include/xenctrl.h +3
-0@@ -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.
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 575
Quoted 5 lines
tools/libxc/include/xenctrl.h +5
-0+* +* 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".
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 578
Quoted 3 lines
tools/libxc/include/xenctrl.h +3
-0+* +* 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.
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 582
Quoted 4 lines
tools/libxc/include/xenctrl.h +4
-0+* +* 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.)
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 585
Quoted 3 lines
tools/libxc/include/xenctrl.h +3
-0+* +* 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?
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 592
Quoted 7 lines
tools/libxc/include/xenctrl.h +7
-0+* 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.
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 594
Quoted 2 lines
tools/libxc/include/xenctrl.h +2
-0+* +* The checkpointing or notifying an guest that the suspend failed is by
"a guest"
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 596
Quoted 2 lines
tools/libxc/include/xenctrl.h +2
-0+* 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.
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 600
Quoted 4 lines
tools/libxc/include/xenctrl.h +4
-0+* +* 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
Quoted 12 lines
tools/libxc/include/xenctrl.h +12
-0+* +* 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.
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 622
Quoted 10 lines
tools/libxc/include/xenctrl.h +7
-0+* +* 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
[email protected]
http://lists.xen.org/xen-devel
Quoted 18 lines · Konrad Rzeszutek Wilk
Document the save and suspend mechanism.
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>--- tools/libxc/include/xenctrl.h | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)tools/libxc/include/xenctrl.h +3
-0@@ -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.
tools/libxc/include/xenctrl.h int xc_domain_destroy(xc_interface *xch, · line 580
Quoted 10 lines
tools/libxc/include/xenctrl.h +10
-0+* +* 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). +* +* HVM guest are the simplest - they suspend via S3 and resume from +* S3. Upon resume they have to re-negotiate with the emulated devices. +* +* PV and PVHVM communate via via hypercalls for suspend (and resume).
"communicate"?
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel