Lazy Restore Using Memory Paging
PATCH 1/1 Lazy Restore Using Memory Paging
This patch series correspond to the work done under the gsoc project implementing lazy restore in libxl/libxc. More information about the project can be found at -
http://wiki.xen.org/wiki/Archived/GSoc_2014#Lazy_restore_using_memory_paging
http://lists.xenproject.org/archives/html/xen-devel/2014-05/msg02069.html
The project is mentored by H. Andres Lagar-Cavilla.
The first patch in the series just modifies xl restore to add another "-l" argument for lazy restore. This argument is passed on from libxl to libxc where the most of the VM restore work is done. Currently libxc just prints a debug message and proceeds with the conventional process. The patches following this patch will be implementing complete functionality for loading emptyVM and then performance improvements.
PATCH 1/1 xl restore: Add a new "-l" lazy switch.
Add a new "-l" option to xl restore which implies use of lazy restore. Plumb the lazy argument from libxl to libxc. Currently libxc just prints a debug message and continue with the conventional process.
Please note that the lazy restore is to be enabled only for HVM guests. If "-l" is passed as an argument to non HVM guest then the process will exit with error.
--- tools/libxc/xc_domain_restore.c | 11 ++++++++++- tools/libxc/xenguest.h | 2 +- tools/libxl/libxl_create.c | 14 +++++++++----- tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_save_callout.c | 2 +- tools/libxl/libxl_save_helper.c | 3 ++- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 16 ++++++++++++++-- tools/libxl/xl_cmdtable.c | 1 + 9 files changed, 40 insertions(+), 11 deletions(-)
tools/libxc/xc_domain_restore.c +10 -1
@@ -1409,7 +1409,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks) {DECLARE_DOMCTL ;
@@ -1470,6 +1470,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,DPRINTF ("%s: starting restore of new domid %u" , __func__, dom); +if ( lazy ) { +DPRINTF ("xc: lazy switch enabled for restore\n" ); + +if ( !hvm ) { +PERROR ("xc: lazy restore called for non HVM guest" ); +return 1 ; + } + } +pagebuf_init (&pagebuf);memset (&tailbuf,0 ,sizeof (tailbuf)); tailbuf.ishvm = hvm;
tools/libxc/xenguest.h +1 -1
@@ -126,7 +126,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks);/** * xc_domain_restore writes a file to disk that contains the device
tools/libxl/libxl_create.c +9 -5
@@ -1348,8 +1348,8 @@ static void domain_create_cb(libxl__egc *egc, int rc, uint32_t domid);static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config, -uint32_t *domid, -int restore_fd,int checkpointed_stream, +uint32_t *domid,int restore_fd, +const libxl_domain_restore_params *restore_params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {
@@ -1361,10 +1361,14 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.guest_config = d_config; cdcs->dcs.restore_fd = restore_fd; cdcs->dcs.callback = domain_create_cb; - cdcs->dcs.checkpointed_stream = checkpointed_stream;libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid; +if (restore_params) { + cdcs->dcs.checkpointed_stream = restore_params->checkpointed_stream; + cdcs->dcs.lazy = restore_params->lazy; + } +initiate_domain_create (egc, &cdcs->dcs);return AO_INPROGRESS ;
@@ -1388,7 +1392,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,const libxl_asyncop_how *ao_how, const libxl_asyncprogress_how *aop_console_how) { - return do_domain_create(ctx, d_config, domid, -1, 0, + return do_domain_create(ctx, d_config, domid, -1, NULL,ao_how ,aop_console_how ); }
@@ -1399,7 +1403,7 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, const libxl_asyncprogress_how *aop_console_how) {return do_domain_create (ctx, d_config, domid, restore_fd, - params->checkpointed_stream, ao_how, aop_console_how); + params, ao_how, aop_console_how); }/*
tools/libxl/libxl_internal.h +1 -0
@@ -2718,6 +2718,7 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;int checkpointed_stream; +int lazy;libxl__domain_build_state build_state;libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;
tools/libxl/libxl_save_callout.c +1 -1
@@ -60,7 +60,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, state->store_domid, state->console_port, state->console_domid, hvm, pae, superpages, no_incr_generationid, - cbflags, dcs->checkpointed_stream, + cbflags, dcs->checkpointed_stream, dcs->lazy, }; dcs->shs.ao = ao;
tools/libxl/libxl_save_helper.c +2 -1
@@ -242,6 +242,7 @@ int main(int argc, char **argv)int no_incr_genidad =strtoul (NEXTARG ,0 ,10 );unsigned cbflags =strtoul (NEXTARG ,0 ,10 );int checkpointed =strtoul (NEXTARG ,0 ,10 ); +int lazy =strtoul (NEXTARG ,0 ,10 );assert (!*++argv);helper_setcallbacks_restore (&helper_restore_callbacks, cbflags);
@@ -254,7 +255,7 @@ int main(int argc, char **argv) r =xc_domain_restore (xch, io_fd, dom, store_evtchn, &store_mfn, store_domid, console_evtchn, &console_mfn, console_domid, hvm, pae, superpages, - no_incr_genidad, checkpointed, &genidad, + no_incr_genidad, checkpointed, lazy, &genidad, &helper_restore_callbacks);helper_stub_restore_results (store_mfn,console_mfn,genidad,0 );complete (r);
tools/libxl/libxl_types.idl +1 -0
@@ -282,6 +282,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), + ("lazy", integer), ]) MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")
tools/libxl/xl_cmdimpl.c +14 -2
@@ -146,6 +146,7 @@ struct domain_create {int paused;int dryrun;int quiet; +int lazy;int vnc;int vncautopass;int console_autoconnect;
@@ -2045,6 +2046,7 @@ static uint32_t create_domain(struct domain_create *dom_info)int daemonize = dom_info->daemonize;int monitor = dom_info->monitor;int paused = dom_info->paused; +int lazy = dom_info->lazy;int vncautopass = dom_info->vncautopass;const char *config_file = dom_info->config_file;const char *extra_config = dom_info->extra_config;
@@ -2237,7 +2239,14 @@ start:if ( restoring ) {libxl_domain_restore_params params; +libxl_domain_create_info *c_info = &d_config.c_info; +if ( lazy && (c_info->type !=LIBXL_DOMAIN_TYPE_HVM ) ) { +fprintf (stderr,"lazy restore should be called for HVM guest only" ); + ret =ERROR_INVAL ; + goto error_out; + } params.checkpointed_stream = dom_info->checkpointed_stream; + params.lazy = lazy; ret = libxl_domain_create_restore(ctx, &d_config, &domid, restore_fd, ¶ms,
@@ -3925,7 +3934,7 @@ int main_restore(int argc, char **argv)const char *config_file =NULL ;struct domain_create dom_info;int paused =0 , debug =0 , daemonize =1 , monitor =1 , - console_autoconnect =0 , vnc =0 , vncautopass =0 ; + console_autoconnect =0 , vnc =0 , vncautopass =0 , lazy =0 ;int opt, rc;static struct option opts[] = { {"vncviewer" ,0 ,0 ,'V' },
@@ -3934,7 +3943,7 @@ int main_restore(int argc, char **argv) {0, 0, 0, 0} }; - SWITCH_FOREACH_OPT(opt, "FhcpdeVA", opts, "restore", 1) { + SWITCH_FOREACH_OPT(opt, "FhcpdleVA", opts, "restore", 1) {case 'c' : console_autoconnect =1 ;break ;
@@ -3957,6 +3966,8 @@ int main_restore(int argc, char **argv)case 'A' : vnc = vncautopass =1 ;break ; +case 'l' : + lazy =1 ; }if (argc-optind ==1 ) {
@@ -3977,6 +3988,7 @@ int main_restore(int argc, char **argv) dom_info.config_file = config_file; dom_info.restore_file = checkpoint_file; dom_info.migrate_fd =-1 ; + dom_info.lazy = lazy; dom_info.vnc = vnc; dom_info.vncautopass = vncautopass; dom_info.console_autoconnect = console_autoconnect;
tools/libxl/xl_cmdtable.c +1 -0
@@ -167,6 +167,7 @@ struct cmd_spec cmd_table[] = {"Restore a domain from a saved state" ,"[options] [<ConfigFile>] <CheckpointFile>" ,"-h Print this help.\n" +"-l Enable lazy restore.\n" "-p Do not unpause domain after restoring it.\n" "-e Do not wait in the background for the death of the domain.\n" "-d Enable debug messages.\n"
Signature · 1 line
1.9.1
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
Quoted 7 lines · Dushyant Behl
Add a new "-l" option to xl restore which implies use of lazy restore. Plumb the lazy argument from libxl to libxc. Currently libxc just prints a debug message and continue with the conventional process.
Please note that the lazy restore is to be enabled only for HVM guests. If "-l" is passed as an argument to non HVM guest then the process will exit with error.
You probably need a documentation entry in the docs directory. Perhaps also explain what 'lazy' restore is versus the normal restore path.
Thanks!
Quoted 253 lines
Signed-off-by Dushyant Behl <[email protected]>--- tools/libxc/xc_domain_restore.c | 11 ++++++++++- tools/libxc/xenguest.h | 2 +- tools/libxl/libxl_create.c | 14 +++++++++----- tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_save_callout.c | 2 +- tools/libxl/libxl_save_helper.c | 3 ++- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 16 ++++++++++++++-- tools/libxl/xl_cmdtable.c | 1 + 9 files changed, 40 insertions(+), 11 deletions(-)tools/libxc/xc_domain_restore.c +10
-1@@ -1409,7 +1409,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks) {DECLARE_DOMCTL ;@@ -1470,6 +1470,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,DPRINTF ("%s: starting restore of new domid %u" , __func__, dom); +if ( lazy ) { +DPRINTF ("xc: lazy switch enabled for restore\n" ); + +if ( !hvm ) { +PERROR ("xc: lazy restore called for non HVM guest" ); +return 1 ; + } + } +pagebuf_init (&pagebuf);memset (&tailbuf,0 ,sizeof (tailbuf)); tailbuf.ishvm = hvm;tools/libxc/xenguest.h +1
-1@@ -126,7 +126,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks);/** * xc_domain_restore writes a file to disk that contains the device tools/libxl/libxl_create.c +9
-5@@ -1348,8 +1348,8 @@ static void domain_create_cb(libxl__egc *egc, int rc, uint32_t domid);static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config, -uint32_t *domid, -int restore_fd,int checkpointed_stream, +uint32_t *domid,int restore_fd, +const libxl_domain_restore_params *restore_params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {@@ -1361,10 +1361,14 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.guest_config = d_config; cdcs->dcs.restore_fd = restore_fd; cdcs->dcs.callback = domain_create_cb; - cdcs->dcs.checkpointed_stream = checkpointed_stream;libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid; +if (restore_params) { + cdcs->dcs.checkpointed_stream = restore_params->checkpointed_stream; + cdcs->dcs.lazy = restore_params->lazy; + } +initiate_domain_create (egc, &cdcs->dcs);return AO_INPROGRESS ;@@ -1388,7 +1392,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,const libxl_asyncop_how *ao_how, const libxl_asyncprogress_how *aop_console_how) { - return do_domain_create(ctx, d_config, domid, -1, 0, + return do_domain_create(ctx, d_config, domid, -1, NULL,ao_how ,aop_console_how ); }@@ -1399,7 +1403,7 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, const libxl_asyncprogress_how *aop_console_how) {return do_domain_create (ctx, d_config, domid, restore_fd, - params->checkpointed_stream, ao_how, aop_console_how); + params, ao_how, aop_console_how); }/* tools/libxl/libxl_internal.h +1
-0@@ -2718,6 +2718,7 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;int checkpointed_stream; +int lazy;libxl__domain_build_state build_state;libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;tools/libxl/libxl_save_callout.c +1
-1@@ -60,7 +60,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, state->store_domid, state->console_port, state->console_domid, hvm, pae, superpages, no_incr_generationid, - cbflags, dcs->checkpointed_stream, + cbflags, dcs->checkpointed_stream, dcs->lazy, }; dcs->shs.ao = ao;tools/libxl/libxl_save_helper.c +2
-1@@ -242,6 +242,7 @@ int main(int argc, char **argv)int no_incr_genidad =strtoul (NEXTARG ,0 ,10 );unsigned cbflags =strtoul (NEXTARG ,0 ,10 );int checkpointed =strtoul (NEXTARG ,0 ,10 ); +int lazy =strtoul (NEXTARG ,0 ,10 );assert (!*++argv);helper_setcallbacks_restore (&helper_restore_callbacks, cbflags);@@ -254,7 +255,7 @@ int main(int argc, char **argv) r =xc_domain_restore (xch, io_fd, dom, store_evtchn, &store_mfn, store_domid, console_evtchn, &console_mfn, console_domid, hvm, pae, superpages, - no_incr_genidad, checkpointed, &genidad, + no_incr_genidad, checkpointed, lazy, &genidad, &helper_restore_callbacks);helper_stub_restore_results (store_mfn,console_mfn,genidad,0 );complete (r);tools/libxl/libxl_types.idl +1
-0@@ -282,6 +282,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), + ("lazy", integer), ]) MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")tools/libxl/xl_cmdimpl.c +14
-2@@ -146,6 +146,7 @@ struct domain_create {int paused;int dryrun;int quiet; +int lazy;int vnc;int vncautopass;int console_autoconnect;@@ -2045,6 +2046,7 @@ static uint32_t create_domain(struct domain_create *dom_info)int daemonize = dom_info->daemonize;int monitor = dom_info->monitor;int paused = dom_info->paused; +int lazy = dom_info->lazy;int vncautopass = dom_info->vncautopass;const char *config_file = dom_info->config_file;const char *extra_config = dom_info->extra_config;@@ -2237,7 +2239,14 @@ start:if ( restoring ) {libxl_domain_restore_params params; +libxl_domain_create_info *c_info = &d_config.c_info; +if ( lazy && (c_info->type !=LIBXL_DOMAIN_TYPE_HVM ) ) { +fprintf (stderr,"lazy restore should be called for HVM guest only" ); + ret =ERROR_INVAL ; + goto error_out; + } params.checkpointed_stream = dom_info->checkpointed_stream; + params.lazy = lazy; ret = libxl_domain_create_restore(ctx, &d_config, &domid, restore_fd, ¶ms,@@ -3925,7 +3934,7 @@ int main_restore(int argc, char **argv)const char *config_file =NULL ;struct domain_create dom_info;int paused =0 , debug =0 , daemonize =1 , monitor =1 , - console_autoconnect =0 , vnc =0 , vncautopass =0 ; + console_autoconnect =0 , vnc =0 , vncautopass =0 , lazy =0 ;int opt, rc;static struct option opts[] = { {"vncviewer" ,0 ,0 ,'V' },@@ -3934,7 +3943,7 @@ int main_restore(int argc, char **argv) {0, 0, 0, 0} }; - SWITCH_FOREACH_OPT(opt, "FhcpdeVA", opts, "restore", 1) { + SWITCH_FOREACH_OPT(opt, "FhcpdleVA", opts, "restore", 1) {case 'c' : console_autoconnect =1 ;break ;@@ -3957,6 +3966,8 @@ int main_restore(int argc, char **argv)case 'A' : vnc = vncautopass =1 ;break ; +case 'l' : + lazy =1 ; }if (argc-optind ==1 ) {@@ -3977,6 +3988,7 @@ int main_restore(int argc, char **argv) dom_info.config_file = config_file; dom_info.restore_file = checkpoint_file; dom_info.migrate_fd =-1 ; + dom_info.lazy = lazy; dom_info.vnc = vnc; dom_info.vncautopass = vncautopass; dom_info.console_autoconnect = console_autoconnect;tools/libxl/xl_cmdtable.c +1
-0@@ -167,6 +167,7 @@ struct cmd_spec cmd_table[] = {"Restore a domain from a saved state" ,"[options] [<ConfigFile>] <CheckpointFile>" ,"-h Print this help.\n" +"-l Enable lazy restore.\n" "-p Do not unpause domain after restoring it.\n" "-e Do not wait in the background for the death of the domain.\n" "-d Enable debug messages.\n" Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
Hi Konrad,
I think you are right, it would be nice to add small documentation regarding the differences between normal restore path and the lazy restore path. I'll try to add the documentation with a bit more explanation, for a quick note if
you missed my previous mail you could find some explanation here.
http://lists.xenproject.org/archives/html/xen-devel/2014-05/msg02069.html
http://wiki.xen.org/wiki/Archived/GSoc_2014#Lazy_restore_using_memory_paging
Thanks and Regards,
Dushaynt Behl
Quoted 267 lines · Konrad Rzeszutek Wilk
Quoted 7 lines · Dushyant Behl
Add a new "-l" option to xl restore which implies use of lazy restore. Plumb the lazy argument from libxl to libxc. Currently libxc just prints a debug message and continue with the conventional process.
Please note that the lazy restore is to be enabled only for HVM guests. If "-l" is passed as an argument to non HVM guest then the process will exit with error.
You probably need a documentation entry in the docs directory. Perhaps also explain what 'lazy' restore is versus the normal restore path.
Thanks!
Quoted 253 lines
Signed-off-by Dushyant Behl <[email protected]>--- tools/libxc/xc_domain_restore.c | 11 ++++++++++- tools/libxc/xenguest.h | 2 +- tools/libxl/libxl_create.c | 14 +++++++++----- tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_save_callout.c | 2 +- tools/libxl/libxl_save_helper.c | 3 ++- tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 16 ++++++++++++++-- tools/libxl/xl_cmdtable.c | 1 + 9 files changed, 40 insertions(+), 11 deletions(-)tools/libxc/xc_domain_restore.c +10
-1@@ -1409,7 +1409,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks) {DECLARE_DOMCTL ;@@ -1470,6 +1470,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,DPRINTF ("%s: starting restore of new domid %u" , __func__, dom); +if ( lazy ) { +DPRINTF ("xc: lazy switch enabled for restore\n" ); + +if ( !hvm ) { +PERROR ("xc: lazy restore called for non HVM guest" ); +return 1 ; + } + } +pagebuf_init (&pagebuf);memset (&tailbuf,0 ,sizeof (tailbuf)); tailbuf.ishvm = hvm;tools/libxc/xenguest.h +1
-1@@ -126,7 +126,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks);/** * xc_domain_restore writes a file to disk that contains the device tools/libxl/libxl_create.c +9
-5@@ -1348,8 +1348,8 @@ static void domain_create_cb(libxl__egc *egc, int rc, uint32_t domid);static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config, -uint32_t *domid, -int restore_fd,int checkpointed_stream, +uint32_t *domid,int restore_fd, +const libxl_domain_restore_params *restore_params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {@@ -1361,10 +1361,14 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.guest_config = d_config; cdcs->dcs.restore_fd = restore_fd; cdcs->dcs.callback = domain_create_cb; - cdcs->dcs.checkpointed_stream = checkpointed_stream;libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid; +if (restore_params) { + cdcs->dcs.checkpointed_stream = restore_params->checkpointed_stream; + cdcs->dcs.lazy = restore_params->lazy; + } +initiate_domain_create (egc, &cdcs->dcs);return AO_INPROGRESS ;@@ -1388,7 +1392,7 @@ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,const libxl_asyncop_how *ao_how, const libxl_asyncprogress_how *aop_console_how) { - return do_domain_create(ctx, d_config, domid, -1, 0, + return do_domain_create(ctx, d_config, domid, -1, NULL,ao_how ,aop_console_how ); }@@ -1399,7 +1403,7 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, const libxl_asyncprogress_how *aop_console_how) {return do_domain_create (ctx, d_config, domid, restore_fd, - params->checkpointed_stream, ao_how, aop_console_how); + params, ao_how, aop_console_how); }/* tools/libxl/libxl_internal.h +1
-0@@ -2718,6 +2718,7 @@ struct libxl__domain_create_state {/* private to domain_create */ int guest_domid;int checkpointed_stream; +int lazy;libxl__domain_build_state build_state;libxl__bootloader_state bl;libxl__stub_dm_spawn_state dmss;tools/libxl/libxl_save_callout.c +1
-1@@ -60,7 +60,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, state->store_domid, state->console_port, state->console_domid, hvm, pae, superpages, no_incr_generationid, - cbflags, dcs->checkpointed_stream, + cbflags, dcs->checkpointed_stream, dcs->lazy, }; dcs->shs.ao = ao;tools/libxl/libxl_save_helper.c +2
-1@@ -242,6 +242,7 @@ int main(int argc, char **argv)int no_incr_genidad =strtoul (NEXTARG ,0 ,10 );unsigned cbflags =strtoul (NEXTARG ,0 ,10 );int checkpointed =strtoul (NEXTARG ,0 ,10 ); +int lazy =strtoul (NEXTARG ,0 ,10 );assert (!*++argv);helper_setcallbacks_restore (&helper_restore_callbacks, cbflags);@@ -254,7 +255,7 @@ int main(int argc, char **argv) r =xc_domain_restore (xch, io_fd, dom, store_evtchn, &store_mfn, store_domid, console_evtchn, &console_mfn, console_domid, hvm, pae, superpages, - no_incr_genidad, checkpointed, &genidad, + no_incr_genidad, checkpointed, lazy, &genidad, &helper_restore_callbacks);helper_stub_restore_results (store_mfn,console_mfn,genidad,0 );complete (r);tools/libxl/libxl_types.idl +1
-0@@ -282,6 +282,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), + ("lazy", integer), ]) MemKB = UInt(64, init_val = "LIBXL_MEMKB_DEFAULT")tools/libxl/xl_cmdimpl.c +14
-2@@ -146,6 +146,7 @@ struct domain_create {int paused;int dryrun;int quiet; +int lazy;int vnc;int vncautopass;int console_autoconnect;@@ -2045,6 +2046,7 @@ static uint32_t create_domain(struct domain_create *dom_info)int daemonize = dom_info->daemonize;int monitor = dom_info->monitor;int paused = dom_info->paused; +int lazy = dom_info->lazy;int vncautopass = dom_info->vncautopass;const char *config_file = dom_info->config_file;const char *extra_config = dom_info->extra_config;@@ -2237,7 +2239,14 @@ start:if ( restoring ) {libxl_domain_restore_params params; +libxl_domain_create_info *c_info = &d_config.c_info; +if ( lazy && (c_info->type !=LIBXL_DOMAIN_TYPE_HVM ) ) { +fprintf (stderr,"lazy restore should be called for HVM guest only" ); + ret =ERROR_INVAL ; + goto error_out; + } params.checkpointed_stream = dom_info->checkpointed_stream; + params.lazy = lazy; ret = libxl_domain_create_restore(ctx, &d_config, &domid, restore_fd, ¶ms,@@ -3925,7 +3934,7 @@ int main_restore(int argc, char **argv)const char *config_file =NULL ;struct domain_create dom_info;int paused =0 , debug =0 , daemonize =1 , monitor =1 , - console_autoconnect =0 , vnc =0 , vncautopass =0 ; + console_autoconnect =0 , vnc =0 , vncautopass =0 , lazy =0 ;int opt, rc;static struct option opts[] = { {"vncviewer" ,0 ,0 ,'V' },@@ -3934,7 +3943,7 @@ int main_restore(int argc, char **argv) {0, 0, 0, 0} }; - SWITCH_FOREACH_OPT(opt, "FhcpdeVA", opts, "restore", 1) { + SWITCH_FOREACH_OPT(opt, "FhcpdleVA", opts, "restore", 1) {case 'c' : console_autoconnect =1 ;break ;@@ -3957,6 +3966,8 @@ int main_restore(int argc, char **argv)case 'A' : vnc = vncautopass =1 ;break ; +case 'l' : + lazy =1 ; }if (argc-optind ==1 ) {@@ -3977,6 +3988,7 @@ int main_restore(int argc, char **argv) dom_info.config_file = config_file; dom_info.restore_file = checkpoint_file; dom_info.migrate_fd =-1 ; + dom_info.lazy = lazy; dom_info.vnc = vnc; dom_info.vncautopass = vncautopass; dom_info.console_autoconnect = console_autoconnect;tools/libxl/xl_cmdtable.c +1
-1@@ -167,6 +167,7 @@ struct cmd_spec cmd_table[] = {"Restore a domain from a saved state" ,"[options] [<ConfigFile>] <CheckpointFile>" ,"-h Print this help.\n" +"-l Enable lazy restore.\n" "-p Do not unpause domain after restoring it.\n" "-e Do not wait in the background for the death of the domain.\n" "-d Enable debug messages.\n" --1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
In reply to Dushyant Behltools/libxc/xc_domain_restore.c int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, · line 1473
Quoted 5 lines · Dushyant Behl
tools/libxc/xc_domain_restore.c +1
-0@@ -1470,6 +1470,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,DPRINTF ("%s: starting restore of new domid %u" , __func__, dom); +if ( lazy ) {
Coding style for libxc (see toplevel CODING_STYLE doc) has { on the next line under the if.
Eventually you will need to target this work on top of the migration v2 work being done by Andrew Cooper, see
http://lists.xen.org/archives/html/xen-devel/2014-04/msg01377.html
You might find it easier to start on top of those patches anyway -- they are a far cleaner base to work from.
Quoted 40 lines
tools/libxc/xc_domain_restore.c +8
-0+DPRINTF ("xc: lazy switch enabled for restore\n" ); + +if ( !hvm ) { +PERROR ("xc: lazy restore called for non HVM guest" ); +return 1 ; + } + } +pagebuf_init (&pagebuf);memset (&tailbuf,0 ,sizeof (tailbuf)); tailbuf.ishvm = hvm;tools/libxc/xenguest.h +1
-1@@ -126,7 +126,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks);/** * xc_domain_restore writes a file to disk that contains the device tools/libxl/libxl_create.c +2
-2@@ -1348,8 +1348,8 @@ static void domain_create_cb(libxl__egc *egc, int rc, uint32_t domid);static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config, -uint32_t *domid, -int restore_fd,int checkpointed_stream, +uint32_t *domid,int restore_fd, +const libxl_domain_restore_params *restore_params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {
tools/libxl/libxl_create.c static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, · line 1368
Quoted 9 lines
tools/libxl/libxl_create.c +2
-1@@ -1361,10 +1361,14 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.guest_config = d_config; cdcs->dcs.restore_fd = restore_fd; cdcs->dcs.callback = domain_create_cb; - cdcs->dcs.checkpointed_stream = checkpointed_stream;libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid; +if (restore_params) { + cdcs->dcs.checkpointed_stream = restore_params->checkpointed_stream;
If !restore_params then cdcs->dcs.checkpointed_stream is no longer explicitly initialised. Have you confirmed that it is zeroed somewhere?
tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 285
Quoted 9 lines
tools/libxl/libxl_types.idl +1
-0@@ -282,6 +282,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), + ("lazy", integer),
Changes to the libxl interface require a LIBXL_HAVE #define in libxl.h, see the comment regarding API compatibility in that file.
tools/libxl/libxl_types.idl int main_restore(int argc, char **argv) · line 3970
Quoted 6 lines
tools/libxl/libxl_types.idl +2
-0@@ -3957,6 +3966,8 @@ int main_restore(int argc, char **argv) case 'A': vnc = vncautopass = 1; break; + case 'l': + lazy = 1;
missing "break;"
tools/libxl/xl_cmdtable.c struct cmd_spec cmd_table[] = { · line 170
Quoted 9 lines
tools/libxl/xl_cmdtable.c +1
-0@@ -167,6 +167,7 @@ struct cmd_spec cmd_table[] = {"Restore a domain from a saved state" ,"[options] [<ConfigFile>] <CheckpointFile>" ,"-h Print this help.\n" +"-l Enable lazy restore.\n"
As Konrad says this also needs documentation, at least in the xl man page.
Ian.
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
Thank you very much for your feedback. I have mentioned the comments inline, Please have a look.
If something is not in place or anything else is missing from my side please mention.
Quoted 9 lines · Ian Campbell
tools/libxc/xc_domain_restore.c int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, · line 1473
Quoted 5 lines · Dushyant Behl
tools/libxc/xc_domain_restore.c +1
-0@@ -1470,6 +1470,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,DPRINTF ("%s: starting restore of new domid %u" , __func__, dom); +if ( lazy ) {Coding style for libxc (see toplevel
CODING_STYLEdoc) has { on the next line under the if.
I checked with the CODING_STYLE doc and the block structure mentioned is the same followed by me ( opening bracket on the same line as the statement). The only exception that is mentioned to have opening bracket for a block on a different line is a function.
Quoted 7 lines
Eventually you will need to target this work on top of the migration v2 work being done by Andrew Cooper, see
http://lists.xen.org/archives/html/xen-devel/2014-04/msg01377.htmlYou might find it easier to start on top of those patches anyway -- they are a far cleaner base to work from.
Sure, I'll try to work on top of those changes.
Quoted 48 lines
Quoted 48 lines
tools/libxc/xc_domain_restore.c +8
-0+DPRINTF ("xc: lazy switch enabled for restore\n" ); + +if ( !hvm ) { +PERROR ("xc: lazy restore called for non HVM guest" ); +return 1 ; + } + } +pagebuf_init (&pagebuf);memset (&tailbuf,0 ,sizeof (tailbuf)); tailbuf.ishvm = hvm;tools/libxc/xenguest.h +1
-1@@ -126,7 +126,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, unsigned long *console_mfn, domid_t console_domid, unsigned int hvm, unsigned int pae, int superpages, int no_incr_generationid, int checkpointed_stream, - unsigned long *vm_generationid_addr, + int lazy, unsigned long *vm_generationid_addr, struct restore_callbacks *callbacks);/** * xc_domain_restore writes a file to disk that contains the device tools/libxl/libxl_create.c +2
-3@@ -1348,8 +1348,8 @@ static void domain_create_cb(libxl__egc *egc, int rc, uint32_t domid);static int do_domain_create (libxl_ctx *ctx,libxl_domain_config *d_config, -uint32_t *domid, -int restore_fd,int checkpointed_stream, +uint32_t *domid,int restore_fd, +const libxl_domain_restore_params *restore_params,const libxl_asyncop_how *ao_how,const libxl_asyncprogress_how *aop_console_how) {@@ -1361,10 +1361,14 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.guest_config = d_config; cdcs->dcs.restore_fd = restore_fd; cdcs->dcs.callback = domain_create_cb; - cdcs->dcs.checkpointed_stream = checkpointed_stream;libxl__ao_progress_gethow (&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid;
Quoted 5 lines
tools/libxl/libxl_create.c static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, · line 1368
Quoted 2 lines
tools/libxl/libxl_create.c +2
-0+if (restore_params) { + cdcs->dcs.checkpointed_stream = restore_params->checkpointed_stream;If !restore_params then
cdcs->dcs.checkpointed_streamis no longer explicitly initialised. Have you confirmed that it is zeroed somewhere?
Actually the struct libxl__app_domain_create_state 'cdcs' is initialized using the macro GCNEW which calls libxl__zalloc to allocate and zero out the memory contents of the structure, so the variables would be initialized to zero.
Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_types.idl +0
-0@@ -282,6 +282,7 @@ libxl_domain_create_info = Struct("domain_create_info",[
Quoted 7 lines
tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 285
Quoted 3 lines
tools/libxl/libxl_types.idl +1
-0libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), + ("lazy", integer),Changes to the libxl interface require a
LIBXL_HAVE#define inlibxl.h, see the comment regarding API compatibility in that file.
I have created a new macro LIBXL_HAVE_RESTORE_PARAMS which is set when the structure libxl_domain_restore_params has lazy as an attribute.
Quoted 8 lines
tools/libxl/libxl_types.idl int main_restore(int argc, char **argv) · line 3970
Quoted 6 lines
tools/libxl/libxl_types.idl +2
-0@@ -3957,6 +3966,8 @@ int main_restore(int argc, char **argv) case 'A': vnc = vncautopass = 1; break; + case 'l': + lazy = 1;missing "break;"
I missed it the first time, added now.
Quoted 13 lines
tools/libxl/xl_cmdtable.c struct cmd_spec cmd_table[] = { · line 170
Quoted 10 lines
tools/libxl/xl_cmdtable.c +1
-0@@ -167,6 +167,7 @@ struct cmd_spec cmd_table[] = {"Restore a domain from a saved state" ,"[options] [<ConfigFile>] <CheckpointFile>" ,"-h Print this help.\n" +"-l Enable lazy restore.\n" As Konrad says this also needs documentation, at least in the xl man page.
Sure, I'll change the documentation accordingly.
Thanks,
Dushyant Behl
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
Quoted 11 lines · Dushyant Behl
Quoted 9 lines · Ian Campbell
tools/libxc/xc_domain_restore.c int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, · line 1473
Quoted 5 lines · Dushyant Behl
tools/libxc/xc_domain_restore.c +1
-0@@ -1470,6 +1470,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,DPRINTF ("%s: starting restore of new domid %u" , __func__, dom); +if ( lazy ) {Coding style for libxc (see toplevel
CODING_STYLEdoc) has { on the next line under the if.
Quoted 4 lines
I checked with the
CODING_STYLEdoc and the block structure mentioned is the same followed by me ( opening bracket on the same line as the statement). The only exception that is mentioned to have opening bracket for a block on a different line is a function.
Not sure which doc you are looking at, CODING_STYLE at the top of the repo applies to tools/libxc/* and says:
Braces ('{' and '}') are usually placed on a line of their own, except for the do/while loop. This is unlike the Linux coding style and unlike K&R. do/while loops are an exception. e.g.:
if ( condition )
{
/* Do stuff. */
}
(Note that libxl has a different style, see tools/libxl/CODING_STYLE)
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_types.idl +0
-0@@ -282,6 +282,7 @@ libxl_domain_create_info = Struct("domain_create_info",[Quoted 7 lines
tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 285
Quoted 3 lines
tools/libxl/libxl_types.idl +1
-0libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), + ("lazy", integer),Changes to the libxl interface require a
LIBXL_HAVE#define inlibxl.h, see the comment regarding API compatibility in that file.
Quoted 2 lines
I have created a new macro
LIBXL_HAVE_RESTORE_PARAMSwhich is set when the structurelibxl_domain_restore_paramshas lazy as an attribute.
That name sounds to generic, it should beLIBXL_HAVE_DOMAIN_RESTORE_PARAMS_LAZY I think.
Ian.
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
Quoted 23 lines · Ian Campbell
Quoted 11 lines · Dushyant Behl
Quoted 9 lines · Ian Campbell
tools/libxc/xc_domain_restore.c int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, · line 1473
Quoted 5 lines · Dushyant Behl
tools/libxc/xc_domain_restore.c +1
-0@@ -1470,6 +1470,15 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,DPRINTF ("%s: starting restore of new domid %u" , __func__, dom); +if ( lazy ) {Coding style for libxc (see toplevel
CODING_STYLEdoc) has { on the next line under the if.Quoted 4 lines
I checked with the
CODING_STYLEdoc and the block structure mentioned is the same followed by me ( opening bracket on the same line as the statement). The only exception that is mentioned to have opening bracket for a block on a different line is a function.Not sure which doc you are looking at,
CODING_STYLEat the top of the repo applies totools/libxc/*and says:
Braces ('{' and '}') are usually placed on a line of their own, except for the do/while loop. This is unlike the Linux coding style and unlike K&R. do/while loops are an exception. e.g.:
Quoted 7 lines
if ( condition )
{
/* Do stuff. */
}(Note that libxl has a different style, see
tools/libxl/CODING_STYLE)
Sorry but the file tools/libxl/CODING_STYLE has mentioned the following statement for block structure -
5. Block structure
Every indented statement is braced apart from blocks that contain just one statement.
The opening brace is on the line that contains the control flow statement that introduces the new block; the closing brace is on the same line as the else keyword, or on a line by itself if there is no else keyword. Examples:
if (a == 5) {
printf("a was 5.\n");
} else if (a == 6) {
printf("a was 6.\n");
} else {
printf("a was something else entirely.\n");
}An exception is the opening brace for a function; for reasons of tradition and clarity it comes on a line by itself:
void a_function(void)
{
do_something();
}The statement which you have mentioned in the mail was actually mentioned in the file xen/CODING_STYLE. I was actually following the file tools/libxl/CODING_STYLE.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
tools/libxl/libxl_types.idl libxl_domain_create_info = Struct("domain_create_info",[ · line 285
Quoted 9 lines
tools/libxl/libxl_types.idl +1
-0@@ -282,6 +282,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ libxl_domain_restore_params = Struct("domain_restore_params", [ ("checkpointed_stream", integer), + ("lazy", integer),Changes to the libxl interface require a
LIBXL_HAVE#define inlibxl.h, see the comment regarding API compatibility in that file.
Quoted 6 lines
Quoted 2 lines
I have created a new macro
LIBXL_HAVE_RESTORE_PARAMSwhich is set when the structurelibxl_domain_restore_paramshas lazy as an attribute.That name sounds to generic, it should be
LIBXL_HAVE_DOMAIN_RESTORE_PARAMS_LAZYI think.
Sure, I'll update the macro name to this.
Thanks and Regards,
Dushyant Behl
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
Quoted 2 lines · Dushyant Behl
The statement which you have mentioned in the mail was actually mentioned in the file xen/CODING_STYLE.
No, its CODING_STYLE not xen/CODING_STYLE and this is the one which applies to tools/libxc (it even says so in the file).
Quoted 1 line
I was actually following the file
tools/libxl/CODING_STYLE.
This is the wrong one to be following for libxc code, which xc_domain_restore certainly is.
Ian.
Re: [PATCH: Lazy Restore] xl restore: Add a new "-l" lazy switch.
Sorry, my bad. I didn't notice that was libxc. Will change it accordingly and try to follow it closely the next time. Thank you for being patient this time.
Quoted 14 lines · Ian Campbell
Quoted 2 lines · Dushyant Behl
The statement which you have mentioned in the mail was actually mentioned in the file xen/CODING_STYLE.
No, its
CODING_STYLEnot xen/CODING_STYLE and this is the one which applies totools/libxc(it even says so in the file).Quoted 1 line
I was actually following the file
tools/libxl/CODING_STYLE.This is the wrong one to be following for libxc code, which
xc_domain_restorecertainly is.Ian.
Quoted 7 lines · Dushyant Behl
This patch series correspond to the work done under the gsoc project implementing lazy restore in libxl/libxc. More information about the project can be found at -
http://wiki.xen.org/wiki/Archived/GSoc_2014#Lazy_restore_using_memory_paging
http://lists.xenproject.org/archives/html/xen-devel/2014-05/msg02069.html
The project is mentored by H. Andres Lagar-Cavilla.
Quoted 6 lines
The first patch in the series just modifies xl restore to add another "-l" argument for lazy restore. This argument is passed on from libxl to libxc where the most of the VM restore work is done. Currently libxc just prints a debug message and proceeds with the conventional process. The patches following this patch will be implementing complete functionality for loading emptyVM and then performance improvements.
Please carry this patch in your series to eventually be committed along with the underlying functionality once it is complete. It should naturally come after the actual functionality...
Ian,