tools/xl: add suspend and resume subcommands
PATCH v3 1/1 tools/xl: add suspend and resume subcommands
From: zithro / Cyril Rébert <[email protected]>
The xl command doesn't provide suspend/resume, so add them :
xl suspend <Domain>
xl resume <Domain>
This patch follows a discussion on XenDevel: when you want the virtualized equivalent of "sleep"-ing a host, it's better to suspend/resume than to pause/unpause a domain.
---
v2
Rename command to just "suspend"
Move inside the HAVE_NO_SUSPEND_RESUME
v3
Move more functions inside HAVE_NO_SUSPEND_RESUME
--- docs/man/xl.1.pod.in | 12 ++++++++++++ tools/xl/xl.h | 2 ++ tools/xl/xl_cmdtable.c | 10 ++++++++++ tools/xl/xl_vmcontrol.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+)
docs/man/xl.1.pod.in +12 -0
@@ -682,6 +682,10 @@ Pass the VNC password to vncviewer via stdin. =back +=item B<resume> I<domain-id> + +Resume a domain, after having been suspended. + =item B<save> [I<OPTIONS>] I<domain-id> I<checkpointfile> [I<configfile>] Saves a running domain to a state file so that it can be restored
@@ -760,6 +764,14 @@ in response to this event. =back +=item B<suspend> I<domain-id> + +Suspend a domain. This is a cooperative operation where the domain must +respond to the xenstore trigger. When in a suspended state the domain +still consumes allocated resources (such as memory), but is not eligible +for scheduling by the Xen hypervisor. It is in a shutdown state, but +not dying. + =item B<sysrq> I<domain-id> I<letter> Send a <Magic System Request> to the domain, each type of request is
tools/xl/xl.h +2 -0
@@ -129,6 +129,8 @@ int main_restore(int argc, char **argv);int main_migrate_receive (int argc,char **argv);int main_save (int argc,char **argv);int main_migrate (int argc,char **argv); +int main_suspend (int argc,char **argv); +int main_resume (int argc,char **argv);#endif int main_dump_core (int argc,char **argv);int main_pause (int argc,char **argv);
tools/xl/xl_cmdtable.c +10 -0
@@ -193,6 +193,16 @@ const struct cmd_spec cmd_table[] = { "Restore a domain from a saved state", "- for internal use only", }, + { "suspend", + &main_suspend, 0, 1, + "Suspend a domain to RAM", + "<Domain>", + }, + { "resume", + &main_resume, 0, 1, + "Resume a domain from RAM", + "<Domain>", + }, #endif { "dump-core", &main_dump_core, 0, 1,
tools/xl/xl_vmcontrol.c +38 -0
@@ -32,6 +32,44 @@static int fd_lock =-1 ; +#ifndef LIBXL_HAVE_NO_SUSPEND_RESUME +static void suspend_domain (uint32_t domid) +{ +libxl_domain_suspend_only (ctx, domid,NULL ); +} + +static void resume_domain (uint32_t domid) +{ +libxl_domain_resume (ctx, domid,1 ,NULL ); +} + +int main_suspend (int argc,char **argv) +{ +int opt; + + SWITCH_FOREACH_OPT(opt, "", NULL, "suspend", 1) { +/* No options */ + } + +suspend_domain (find_domain (argv[optind])); + +return EXIT_SUCCESS ; +} + +int main_resume (int argc,char **argv) +{ +int opt; + + SWITCH_FOREACH_OPT(opt, "", NULL, "resume", 1) { +/* No options */ + } + +resume_domain (find_domain (argv[optind])); + +return EXIT_SUCCESS ; +} +#endif +static void pause_domain (uint32_t domid) {libxl_domain_pause (ctx, domid,NULL );
Signature · 1 line
2.34.1
Quoted 6 lines · Jason Andryuk
From: zithro / Cyril Rébert <[email protected]>
The xl command doesn't provide suspend/resume, so add them :
xl suspend <Domain>
xl resume <Domain>
Quoted 8 lines
This patch follows a discussion on XenDevel: when you want the virtualized equivalent of "sleep"-ing a host, it's better to suspend/resume than to pause/unpause a domain.
Suggested-by Andrew Cooper <[email protected]>Suggested-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Cyril Rébert (zithro) <[email protected]>Signed-off-by Jason Andryuk <[email protected]>
Thanks,
--
Anthony Perard | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 11 lines · Anthony PERARD
Quoted 10 lines · Jason Andryuk
From: zithro / Cyril Rébert <[email protected]>
The xl command doesn't provide suspend/resume, so add them :
xl suspend <Domain>
xl resume <Domain>This patch follows a discussion on XenDevel: when you want the virtualized equivalent of "sleep"-ing a host, it's better to suspend/resume than to pause/unpause a domain.
Quoted 5 lines
Quoted 4 lines
Suggested-by Andrew Cooper <[email protected]>Suggested-by Marek Marczykowski-Górecki <[email protected]>Signed-off-by Cyril Rébert (zithro) <[email protected]>Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Anthony PERARD <[email protected]>
Committed. This definitely warrants a note in CHANGELOG.md
~Andrew