diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-04-12 17:46:10 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-04-12 17:46:10 +0100 |
commit | 01745ae6b53dfff62f2cd4d0ebd3500075b1b3d5 (patch) | |
tree | 52c7adfee7506ba923f1ec01b1ffa5abb111dffb /tools/libxl/libxlu_cfg.c | |
parent | b175259586a64137ca5dc55a51181eb1abedd1fb (diff) | |
download | xen-01745ae6b53dfff62f2cd4d0ebd3500075b1b3d5.tar.gz xen-01745ae6b53dfff62f2cd4d0ebd3500075b1b3d5.tar.bz2 xen-01745ae6b53dfff62f2cd4d0ebd3500075b1b3d5.zip |
xl: New savefile format. Save domain config when saving a domain.
We introduce a new format for saved domains. The new format, in
contrast to the old:
* Has a magic number which can distinguish it from other kinds of
file
* Is extensible
* Can contains the domain configuration file
On domain creation we remember the actual config file used (using the
toolstack data feature of libxl, just introduced), and by default save
it to the save file.
However, options are provided for the following:
* When saving a domain, supplying an alternative config file to
store in the savefile.
* When restoring a domain, supplying an alternative config file.
If a domain is restored with a different config file, it is the
responsibility of the xl user to ensure that the two configs are
"compatible". Changing the targets of virtual devices is supported;
changing other features of the domain is not recommended. Bad changes
may lead to undefined behaviour in the domain, and are in practice
likely to cause resume failures or crashes.
Old format save files generated by old versions of xl are not
supported.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxlu_cfg.c')
-rw-r--r-- | tools/libxl/libxlu_cfg.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c index 632c371cf5..69a6b24b2d 100644 --- a/tools/libxl/libxlu_cfg.c +++ b/tools/libxl/libxlu_cfg.c @@ -53,6 +53,43 @@ int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) { return ctx.err; } +int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { + CfgParseContext ctx; + int e, r; + YY_BUFFER_STATE buf= 0; + + ctx.scanner= 0; + ctx.cfg= cfg; + ctx.err= 0; + ctx.lexerrlineno= -1; + + e= xlu__cfg_yylex_init_extra(&ctx, &ctx.scanner); + if (e) { + fprintf(cfg->report,"%s: unable to create scanner: %s\n", + cfg->filename, strerror(e)); + ctx.err= e; + ctx.scanner= 0; + goto xe; + } + + buf = xlu__cfg_yy_scan_bytes(data, length, ctx.scanner); + if (!buf) { + fprintf(cfg->report,"%s: unable to allocate scanner buffer\n", + cfg->filename); + ctx.err= ENOMEM; + goto xe; + } + + r= xlu__cfg_yyparse(&ctx); + if (r) assert(ctx.err); + + xe: + if (buf) xlu__cfg_yy_delete_buffer(buf, ctx.scanner); + if (ctx.scanner) xlu__cfg_yylex_destroy(ctx.scanner); + + return ctx.err; +} + void xlu__cfg_set_free(XLU_ConfigSetting *set) { free(set->name); free(set->values); |