Replace config file parser for "xl"
PATCH 1/1 Replace config file parser for "xl"
This provides a replacement config file parser for "xl" based on bison and flex.
Benefits:
* proper error reporting with line numbers
* parser can understand nearly all "xm" configuration files directly (doesn't understand Python code but should do everything else)
* parser also understands the ;-infested "xl" style files
* removes the dependency on libconfig
* better checking for certain kinds of mistakes
* eliminates the strange "massage file and try again" code
This is intended to support all config files currently supported by "xl" and almost all files supported by "xm". (NB that whether a feature works depends on the implementation of that feature in xl/libxl of course.)
This patch also introduces a new library "libxlutil" which is mainly for the benefit of "xl". Users of libxl do not need to use libxlutil, but they can do so if they want to parse "xl" files without being "xl".
Ian.
.hgignore +2 -1
@@ -180,7 +180,8 @@ ^tools/libxen/libxenapi- ^tools/libxen/test/test_bindings$ ^tools/libxen/test/test_event_handling$ -^tools/libxl/libconfig.*$ +^tools/libxl/libxlu_cfg_[yl]\.[ch]$ +^tools/libxl/libxlu_cfg_y\.output ^tools/libxl/xl$ ^tools/libaio/src/.*\.ol$ ^tools/libaio/src/.*\.os$
Config.mk +3 -0
@@ -34,6 +34,9 @@ EXTRA_INCLUDES += $(EXTRA_PREFIX)/include EXTRA_LIB += $(EXTRA_PREFIX)/$(LIBLEAFDIR) endif + +BISON ?= bison +FLEX ?= flex PYTHON ?= python PYTHON_PREFIX_ARG ?= --prefix="$(PREFIX)"
README +1 -0
@@ -49,6 +49,7 @@ * bridge-utils package (/sbin/brctl) * iproute package (/sbin/ip) * hotplug or udev + * GNU bison and GNU flex [NB. Unless noted otherwise, all the following steps should be performed with root privileges.]
tools/libxl/Makefile +41 -18
98 lines not on this page · raw message
tools/libxl/libxlu_cfg.c new file +341 -0
341 lines not on this page · raw message
tools/libxl/libxlu_cfg_i.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef LIBXLU_CFG_I_H +#define LIBXLU_CFG_I_H + +#include "libxlu_internal.h" +#include "libxlu_cfg_y.h" + +void xlu__cfg_set_free (XLU_ConfigSetting *set); +XLU_ConfigSetting *xlu__cfg_set_mk (CfgParseContext *,int alloc,char *atom); +void xlu__cfg_set_add (CfgParseContext *,XLU_ConfigSetting *set,char *atom); +void xlu__cfg_set_store (CfgParseContext *,char *name, +XLU_ConfigSetting *set,int lineno); + +char *xlu__cfgl_strdup (CfgParseContext *,const char *src); +char *xlu__cfgl_dequote (CfgParseContext *,const char *src); + +void xlu__cfg_yyerror (YYLTYPE *locp,CfgParseContext *,char const *msg); +void xlu__cfgl_lexicalerror (CfgParseContext *,char const *msg); + + + +/* Why oh why does bison not declare this in its autogenerated .h ? */ +int xlu__cfg_yyparse (CfgParseContext *ctx); + + +#endif /*LIBXLU_CFG_I_H*/
tools/libxl/libxlu_cfg_l.l new file +74 -0
74 lines not on this page · raw message
tools/libxl/libxlu_cfg_y.y new file +57 -0
57 lines not on this page · raw message
tools/libxl/libxlu_internal.h new file +48 -0
48 lines not on this page · raw message
tools/libxl/libxlutil.h new file +58 -0
58 lines not on this page · raw message
tools/libxl/xl.c +52 -111
286 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 17 lines · Ian Jackson
This provides a replacement config file parser for "xl" based on bison and flex.
Benefits:
* proper error reporting with line numbers
* parser can understand nearly all "xm" configuration files directly (doesn't understand Python code but should do everything else)
* parser also understands the ;-infested "xl" style files
* removes the dependency on libconfig
* better checking for certain kinds of mistakes
* eliminates the strange "massage file and try again" codeThis is intended to support all config files currently supported by "xl" and almost all files supported by "xm". (NB that whether a feature works depends on the implementation of that feature in xl/libxl of course.)
Quoted 4 lines
This patch also introduces a new library "libxlutil" which is mainly for the benefit of "xl". Users of libxl do not need to use libxlutil, but they can do so if they want to parse "xl" files without being "xl".
this is merely replacing a library dependency by a compilation dependency, plus the burden on maintaining a ad-hoc grammar. At least it would probably be useful to take the same approch as the linux kernel, i.e. checking bison/flex output in the repository to account for bison annoying volatility.
however since it's well separated from libxl,
Signature · 1 line
Vincent
PATCH 1/1 Fix config file interpretation when pci= not specified
In reply to Ian JacksonMy code for interpreting the results of the new config parser has undefined behaviour in the case when pci=... is not specified. Bad luck meant it worked for me in my tests. This patch fixes it.
# HG changeset patch
# User Ian Jackson <[email protected]>
# Date 1267728147 0
# Node ID 2c7d21b063a59bfcc5c327820ffe1b15cf6915ac
# Parent 32c721712bcef07b8e24834abbf1f23ef49640ed
xl: Fix undefined behaviour when pci not specified in input file
tools/libxl/xl.c +1 -1
@@ -590,7 +590,7 @@if (!xlu_cfg_get_long (config,"pci_power_mgmt" , &l)) pci_power_mgmt = l; -if (xlu_cfg_get_list (config,"pci" , &pcis,0 )) { +if (!xlu_cfg_get_list (config,"pci" , &pcis,0 )) { *num_pcidevs =0 ; *pcidevs =NULL ;while ((buf =xlu_cfg_get_listitem (pcis, *num_pcidevs)) !=NULL ) {