From b4a5154ad8cd140c384f3da0fe890cff91ce7408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20S=2E=20Montero?= Date: Mon, 21 Dec 2009 12:02:40 +0000 Subject: [PATCH 01/25] Created a new branch for better parsing of context and Requirements attribute git-svn-id: http://svn.opennebula.org/one/branches/DEVELOPMENT/Context_Requirements@959 3034c82b-c49b-4eb3-8279-a7acafdc01c0 From 88e97aca68cd47e20a0c270bbee7be54076d8867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20S=2E=20Montero?= Date: Mon, 21 Dec 2009 12:07:26 +0000 Subject: [PATCH 02/25] parse requirements git-svn-id: http://svn.opennebula.org/one/branches/DEVELOPMENT/Context_Requirements@960 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- include/VirtualMachinePool.h | 7 +++ src/vm/VirtualMachinePool.cc | 92 ++++++++++++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 10 deletions(-) diff --git a/include/VirtualMachinePool.h b/include/VirtualMachinePool.h index fcded8b6c8..9a663663dc 100644 --- a/include/VirtualMachinePool.h +++ b/include/VirtualMachinePool.h @@ -162,6 +162,13 @@ private: */ void generate_context(int vm_id, Attribute * attr); + /** + * Generate a parsed requirements string + * @param vm_id, ID of the VM to generate context for + * @param attr, the template REQUIREMENTS attribute (the first one) + */ + void generate_requirements(int vm_id, Attribute * attr); + /** * Factory method to produce VM objects * @return a pointer to the new VM diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index acbed2577e..ee24bd85e3 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -158,9 +158,10 @@ int VirtualMachinePool::allocate ( string name; char * error_msg; - int rc, num_attr; + int rc, num_context, num_reqs; - vector attrs; + vector context; + vector reqs; // ------------------------------------------------------------------------ // Build a new Virtual Machine object @@ -179,7 +180,7 @@ int VirtualMachinePool::allocate ( vm->uid = uid; // ------------------------------------------------------------------------ - // Parse template and keep CONTEXT apart + // Parse template and keep CONTEXT and REQUIREMENTS apart // ------------------------------------------------------------------------ rc = vm->vm_template.parse(stemplate,&error_msg); @@ -194,8 +195,8 @@ int VirtualMachinePool::allocate ( return -2; } - vm->vm_template.remove("CONTEXT",attrs); - + num_context = vm->vm_template.remove("CONTEXT",context); + num_reqs = vm->vm_template.remove("REQUIREMENTS",reqs); // ------------------------------------------------------------------------ // Insert the Object in the pool @@ -212,15 +213,32 @@ int VirtualMachinePool::allocate ( // Insert parsed context in the VM template and clean-up // ------------------------------------------------------------------------ - if ((num_attr = (int) attrs.size()) > 0) + if ( num_context > 0) { - generate_context(*oid,attrs[0]); + generate_context(*oid,context[0]); - for (int i = 0; i < num_attr ; i++) + for (int i = 0; i < num_context ; i++) { - if (attrs[i] != 0) + if (context[i] != 0) { - delete attrs[i]; + delete context[i]; + } + } + } + + // ------------------------------------------------------------------------ + // Parse the Requirements + // ------------------------------------------------------------------------ + + if ( num_reqs > 0 ) + { + generate_requirements(*oid,reqs[0]); + + for (int i = 0; i < num_reqs ; i++) + { + if (reqs[i] != 0) + { + delete reqs[i]; } } } @@ -332,4 +350,58 @@ void VirtualMachinePool::generate_context(int vm_id, Attribute * attr) vm->unlock(); } +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +void VirtualMachinePool::generate_requirements(int vm_id, Attribute * attr) +{ + SingleAttribute * reqs; + string parsed; + char * error_msg; + int rc; + + SingleAttribute * reqs_parsed; + VirtualMachine * vm; + + reqs = dynamic_cast(attr); + + if (reqs == 0) + { + return; + } + + rc = VirtualMachine::parse_template_attribute(vm_id,reqs->value(), + parsed,&error_msg); + + if ( rc != 0 ) + { + if (error_msg != 0) + { + ostringstream oss; + + oss << error_msg << ": " << reqs->value(); + free(error_msg); + + Nebula::log("ONE", Log::ERROR, oss); + } + + return; + } + + reqs_parsed = new SingleAttribute("REQUIREMENTS",parsed); + + vm = get(vm_id,true); + + if ( vm == 0 ) + { + delete reqs_parsed; + return; + } + + if ( vm->insert_template_attribute(db,reqs_parsed) != 0 ) + { + delete reqs_parsed; + } + + vm->unlock(); +} From 28e9d41ab1c6e25cb84acffd07a936cdaf3cc378 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 5 Mar 2010 19:17:52 +0100 Subject: [PATCH 03/25] feature #189: Moved attribute parsing to VirtualMachine class (get rid of cross references). Added Requirements parsing and initial vnc_port generation --- include/VirtualMachine.h | 53 ++-- include/VirtualMachinePool.h | 14 - src/host/host_parser.c | 44 ++- src/host/host_rank.cc | 326 +++++++++++--------- src/host/host_rank.h | 47 +-- src/host/host_requirements.cc | 336 +++++++++++--------- src/host/host_requirements.h | 47 +-- src/template/template_parser.c | 44 ++- src/template/template_syntax.cc | 326 +++++++++++--------- src/template/template_syntax.h | 53 ++-- src/vm/VirtualMachine.cc | 321 ++++++++++++++----- src/vm/VirtualMachinePool.cc | 167 +--------- src/vm/vm_var_parser.c | 165 +++++----- src/vm/vm_var_parser.l | 6 +- src/vm/vm_var_syntax.cc | 527 ++++++++++++++------------------ src/vm/vm_var_syntax.h | 55 ++-- src/vm/vm_var_syntax.y | 78 +---- 17 files changed, 1317 insertions(+), 1292 deletions(-) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 850a24e484..d26b26afca 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -619,23 +619,6 @@ public: */ int parse_template_attribute(const string& attribute, string& parsed); - - /** - * Parse a string and substitute variables (e.g. $NAME) using the VM - * template values (blocking-free version for cross references): - * @param vm_id ID of the VM used to substitute the variables - * @param attribute, the string to be parsed - * @param parsed, the resulting parsed string - * @param error_msg, string describing the syntax error - * @return 0 on success. - */ - static int parse_template_attribute(int vm_id, - const string& attribute, - string& parsed, - char ** error_msg) - { - return parse_attribute(0,vm_id,attribute,parsed,error_msg); - } // ------------------------------------------------------------------------ // States @@ -982,23 +965,25 @@ private: static pthread_mutex_t lex_mutex; /** - * Parse a string and substitute variables (e.g. $NAME) using template - * values: - * @param vm pointer to VirtualMachine if not 0 the template of that VM - * will be used. - * @param vm_id ID of the VM used to substitute the variables, used if vm - * is 0 - * @param attribute, the string to be parsed - * @param parsed, the resulting parsed string - * @param error_msg, string describing the syntax error - * @return 0 on success. - */ - static int parse_attribute(VirtualMachine * vm, - int vm_id, - const string& attribute, - string& parsed, - char ** error_msg); - + * Parse the "CONTEXT" attribute of the template by substituting + * $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE] + * @return 0 on success + */ + int parse_context(); + + /** + * Parse the "REQUIREMENTS" attribute of the template by substituting + * $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE] + * @return 0 on success + */ + int parse_requirements(); + + /** + * Parse the "GRAPHICS" attribute and generates a default PORT if not + * defined + */ + void parse_graphics(); + protected: //************************************************************************** diff --git a/include/VirtualMachinePool.h b/include/VirtualMachinePool.h index 9a663663dc..28bd989bbc 100644 --- a/include/VirtualMachinePool.h +++ b/include/VirtualMachinePool.h @@ -155,20 +155,6 @@ public: } private: - /** - * Generate context file to be sourced upon VM booting - * @param vm_id, ID of the VM to generate context for - * @param attr, the template CONTEXT attribute (the first one) - */ - void generate_context(int vm_id, Attribute * attr); - - /** - * Generate a parsed requirements string - * @param vm_id, ID of the VM to generate context for - * @param attr, the template REQUIREMENTS attribute (the first one) - */ - void generate_requirements(int vm_id, Attribute * attr); - /** * Factory method to produce VM objects * @return a pointer to the new VM diff --git a/src/host/host_parser.c b/src/host/host_parser.c index 4de6dc32fe..8e98559d18 100644 --- a/src/host/host_parser.c +++ b/src/host/host_parser.c @@ -28,7 +28,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -211,13 +211,6 @@ extern FILE *host_in, *host_out; #define unput(c) yyunput( c, (yytext_ptr) ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -531,7 +524,7 @@ char *host_text; #define YY_USER_ACTION llocp->first_line = host_lineno; \ llocp->first_column = llocp->last_column; \ llocp->last_column += host_leng; -#line 535 "host_parser.c" +#line 528 "host_parser.c" #define INITIAL 0 @@ -549,6 +542,35 @@ char *host_text; static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int host_lex_destroy (void ); + +int host_get_debug (void ); + +void host_set_debug (int debug_flag ); + +YY_EXTRA_TYPE host_get_extra (void ); + +void host_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *host_get_in (void ); + +void host_set_in (FILE * in_str ); + +FILE *host_get_out (void ); + +void host_set_out (FILE * out_str ); + +int host_get_leng (void ); + +char *host_get_text (void ); + +int host_get_lineno (void ); + +void host_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -686,7 +708,7 @@ YY_DECL /* --- Tokens --- */ -#line 690 "host_parser.c" +#line 712 "host_parser.c" if ( !(yy_init) ) { @@ -829,7 +851,7 @@ YY_RULE_SETUP #line 66 "host_parser.l" ECHO; YY_BREAK -#line 833 "host_parser.c" +#line 855 "host_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); diff --git a/src/host/host_rank.cc b/src/host/host_rank.cc index 9987a05693..222dba22bb 100644 --- a/src/host/host_rank.cc +++ b/src/host/host_rank.cc @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,39 +54,28 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 1 /* Substitute the variable and function names. */ -#define yyparse host_rank_parse -#define yylex host_rank_lex -#define yyerror host_rank_error -#define yylval host_rank_lval -#define yychar host_rank_char -#define yydebug host_rank_debug -#define yynerrs host_rank_nerrs -#define yylloc host_rank_lloc - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - INTEGER = 258, - STRING = 259, - FLOAT = 260 - }; -#endif -/* Tokens. */ -#define INTEGER 258 -#define STRING 259 -#define FLOAT 260 - - - +#define yyparse host_rank_parse +#define yylex host_rank_lex +#define yyerror host_rank_error +#define yylval host_rank_lval +#define yychar host_rank_char +#define yydebug host_rank_debug +#define yynerrs host_rank_nerrs +#define yylloc host_rank_lloc /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 18 "host_rank.y" #include @@ -122,6 +110,9 @@ int host_rank_parse(Host * host, int& result, char ** errmsg); +/* Line 189 of yacc.c */ +#line 115 "host_rank.cc" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -140,20 +131,40 @@ int host_rank_parse(Host * host, int& result, char ** errmsg); # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INTEGER = 258, + STRING = 259, + FLOAT = 260 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 55 "host_rank.y" { + +/* Line 214 of yacc.c */ +#line 55 "host_rank.y" + char * val_str; int val_int; float val_float; -} -/* Line 187 of yacc.c. */ -#line 153 "host_rank.cc" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 164 "host_rank.cc" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED @@ -173,8 +184,8 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 178 "host_rank.cc" +/* Line 264 of yacc.c */ +#line 189 "host_rank.cc" #ifdef short # undef short @@ -249,14 +260,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -338,9 +349,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - YYLTYPE yyls; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ @@ -375,12 +386,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -754,17 +765,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, host, result, error_ms #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -802,11 +816,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, host, result, error_msg) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , host, result, error_msg); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1094,10 +1108,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, host, result, error_msg) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1116,10 +1128,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1145,24 +1156,59 @@ yyparse (host, result, error_msg) #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc; - int yystate; + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1170,63 +1216,37 @@ YYLTYPE yylloc; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; yylsp = yyls; + #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; + yylloc.first_column = yylloc.last_column = 1; #endif goto yysetstate; @@ -1265,6 +1285,7 @@ YYLTYPE yylloc; &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; @@ -1286,9 +1307,9 @@ YYLTYPE yylloc; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - YYSTACK_RELOCATE (yyls); + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1309,6 +1330,9 @@ YYLTYPE yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1317,16 +1341,16 @@ YYLTYPE yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1358,20 +1382,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1412,16 +1432,22 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 77 "host_rank.y" { result = static_cast((yyvsp[(1) - (1)].val_float));;} break; case 3: + +/* Line 1455 of yacc.c */ #line 78 "host_rank.y" { result = 0; ;} break; case 4: + +/* Line 1455 of yacc.c */ #line 81 "host_rank.y" { string val; host->get_template_attribute((yyvsp[(1) - (1)].val_str),val); @@ -1430,48 +1456,65 @@ yyreduce: break; case 5: + +/* Line 1455 of yacc.c */ #line 85 "host_rank.y" { (yyval.val_float) = (yyvsp[(1) - (1)].val_float); ;} break; case 6: + +/* Line 1455 of yacc.c */ #line 86 "host_rank.y" { (yyval.val_float) = static_cast((yyvsp[(1) - (1)].val_int)); ;} break; case 7: + +/* Line 1455 of yacc.c */ #line 87 "host_rank.y" { (yyval.val_float) = (yyvsp[(1) - (3)].val_float) + (yyvsp[(3) - (3)].val_float);;} break; case 8: + +/* Line 1455 of yacc.c */ #line 88 "host_rank.y" { (yyval.val_float) = (yyvsp[(1) - (3)].val_float) - (yyvsp[(3) - (3)].val_float);;} break; case 9: + +/* Line 1455 of yacc.c */ #line 89 "host_rank.y" { (yyval.val_float) = (yyvsp[(1) - (3)].val_float) * (yyvsp[(3) - (3)].val_float);;} break; case 10: + +/* Line 1455 of yacc.c */ #line 90 "host_rank.y" { (yyval.val_float) = (yyvsp[(1) - (3)].val_float) / (yyvsp[(3) - (3)].val_float);;} break; case 11: + +/* Line 1455 of yacc.c */ #line 91 "host_rank.y" { (yyval.val_float) = - (yyvsp[(2) - (2)].val_float);;} break; case 12: + +/* Line 1455 of yacc.c */ #line 92 "host_rank.y" { (yyval.val_float) = (yyvsp[(2) - (3)].val_float);;} break; -/* Line 1267 of yacc.c. */ -#line 1475 "host_rank.cc" + +/* Line 1455 of yacc.c */ +#line 1518 "host_rank.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1547,7 +1590,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1564,7 +1607,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1622,14 +1665,11 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; @@ -1654,7 +1694,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1665,7 +1705,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc, host, result, error_msg); /* Do not reclaim the symbols of the rule which action triggered @@ -1691,6 +1731,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 95 "host_rank.y" diff --git a/src/host/host_rank.h b/src/host/host_rank.h index 954d6d595f..aec4e8f66c 100644 --- a/src/host/host_rank.h +++ b/src/host/host_rank.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -44,28 +44,28 @@ FLOAT = 260 }; #endif -/* Tokens. */ -#define INTEGER 258 -#define STRING 259 -#define FLOAT 260 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 55 "host_rank.y" { + +/* Line 1676 of yacc.c */ +#line 55 "host_rank.y" + char * val_str; int val_int; float val_float; -} -/* Line 1489 of yacc.c. */ + + + +/* Line 1676 of yacc.c */ #line 65 "host_rank.hh" - YYSTYPE; +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif @@ -84,3 +84,4 @@ typedef struct YYLTYPE #endif + diff --git a/src/host/host_requirements.cc b/src/host/host_requirements.cc index 4b73b96e66..e5cf480bda 100644 --- a/src/host/host_requirements.cc +++ b/src/host/host_requirements.cc @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,39 +54,28 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 1 /* Substitute the variable and function names. */ -#define yyparse host_requirements_parse -#define yylex host_requirements_lex -#define yyerror host_requirements_error -#define yylval host_requirements_lval -#define yychar host_requirements_char -#define yydebug host_requirements_debug -#define yynerrs host_requirements_nerrs -#define yylloc host_requirements_lloc - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - INTEGER = 258, - STRING = 259, - FLOAT = 260 - }; -#endif -/* Tokens. */ -#define INTEGER 258 -#define STRING 259 -#define FLOAT 260 - - - +#define yyparse host_requirements_parse +#define yylex host_requirements_lex +#define yyerror host_requirements_error +#define yylval host_requirements_lval +#define yychar host_requirements_char +#define yydebug host_requirements_debug +#define yynerrs host_requirements_nerrs +#define yylloc host_requirements_lloc /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 18 "host_requirements.y" #include @@ -122,6 +110,9 @@ int host_requirements_parse(Host * host, bool& result, char ** errmsg); +/* Line 189 of yacc.c */ +#line 115 "host_requirements.cc" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -140,20 +131,40 @@ int host_requirements_parse(Host * host, bool& result, char ** errmsg); # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + INTEGER = 258, + STRING = 259, + FLOAT = 260 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 55 "host_requirements.y" { + +/* Line 214 of yacc.c */ +#line 55 "host_requirements.y" + char * val_str; int val_int; float val_float; -} -/* Line 187 of yacc.c. */ -#line 153 "host_requirements.cc" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 164 "host_requirements.cc" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED @@ -173,8 +184,8 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 178 "host_requirements.cc" +/* Line 264 of yacc.c */ +#line 189 "host_requirements.cc" #ifdef short # undef short @@ -249,14 +260,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -338,9 +349,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - YYLTYPE yyls; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ @@ -375,12 +386,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -760,17 +771,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, host, result, error_ms #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -808,11 +822,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, host, result, error_msg) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , host, result, error_msg); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1100,10 +1114,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, host, result, error_msg) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1122,10 +1134,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1151,24 +1162,59 @@ yyparse (host, result, error_msg) #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc; - int yystate; + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1176,63 +1222,37 @@ YYLTYPE yylloc; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; yylsp = yyls; + #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; + yylloc.first_column = yylloc.last_column = 1; #endif goto yysetstate; @@ -1271,6 +1291,7 @@ YYLTYPE yylloc; &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; @@ -1292,9 +1313,9 @@ YYLTYPE yylloc; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - YYSTACK_RELOCATE (yyls); + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1315,6 +1336,9 @@ YYLTYPE yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1323,16 +1347,16 @@ YYLTYPE yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1364,20 +1388,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1418,16 +1438,22 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 75 "host_requirements.y" { result=(yyvsp[(1) - (1)].val_int); ;} break; case 3: + +/* Line 1455 of yacc.c */ #line 76 "host_requirements.y" { result=true; ;} break; case 4: + +/* Line 1455 of yacc.c */ #line 79 "host_requirements.y" { int val; @@ -1438,6 +1464,8 @@ yyreduce: break; case 5: + +/* Line 1455 of yacc.c */ #line 86 "host_requirements.y" { int val; @@ -1448,6 +1476,8 @@ yyreduce: break; case 6: + +/* Line 1455 of yacc.c */ #line 93 "host_requirements.y" { int val; @@ -1458,6 +1488,8 @@ yyreduce: break; case 7: + +/* Line 1455 of yacc.c */ #line 100 "host_requirements.y" { int val; @@ -1468,6 +1500,8 @@ yyreduce: break; case 8: + +/* Line 1455 of yacc.c */ #line 107 "host_requirements.y" { string val; @@ -1478,6 +1512,8 @@ yyreduce: break; case 9: + +/* Line 1455 of yacc.c */ #line 114 "host_requirements.y" { string val; @@ -1488,6 +1524,8 @@ yyreduce: break; case 10: + +/* Line 1455 of yacc.c */ #line 121 "host_requirements.y" { string val; @@ -1498,6 +1536,8 @@ yyreduce: break; case 11: + +/* Line 1455 of yacc.c */ #line 128 "host_requirements.y" { string val; @@ -1508,6 +1548,8 @@ yyreduce: break; case 12: + +/* Line 1455 of yacc.c */ #line 135 "host_requirements.y" { string val; @@ -1519,6 +1561,8 @@ yyreduce: break; case 13: + +/* Line 1455 of yacc.c */ #line 143 "host_requirements.y" { string val; @@ -1530,28 +1574,37 @@ yyreduce: break; case 14: + +/* Line 1455 of yacc.c */ #line 151 "host_requirements.y" { (yyval.val_int) = (yyvsp[(1) - (3)].val_int) && (yyvsp[(3) - (3)].val_int); ;} break; case 15: + +/* Line 1455 of yacc.c */ #line 152 "host_requirements.y" { (yyval.val_int) = (yyvsp[(1) - (3)].val_int) || (yyvsp[(3) - (3)].val_int); ;} break; case 16: + +/* Line 1455 of yacc.c */ #line 153 "host_requirements.y" { (yyval.val_int) = ! (yyvsp[(2) - (2)].val_int); ;} break; case 17: + +/* Line 1455 of yacc.c */ #line 154 "host_requirements.y" { (yyval.val_int) = (yyvsp[(2) - (3)].val_int); ;} break; -/* Line 1267 of yacc.c. */ -#line 1555 "host_requirements.cc" + +/* Line 1455 of yacc.c */ +#line 1608 "host_requirements.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1627,7 +1680,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1644,7 +1697,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1702,14 +1755,11 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; @@ -1734,7 +1784,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1745,7 +1795,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc, host, result, error_msg); /* Do not reclaim the symbols of the rule which action triggered @@ -1771,6 +1821,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 157 "host_requirements.y" diff --git a/src/host/host_requirements.h b/src/host/host_requirements.h index 8178da758d..96a2084ad0 100644 --- a/src/host/host_requirements.h +++ b/src/host/host_requirements.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -44,28 +44,28 @@ FLOAT = 260 }; #endif -/* Tokens. */ -#define INTEGER 258 -#define STRING 259 -#define FLOAT 260 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 55 "host_requirements.y" { + +/* Line 1676 of yacc.c */ +#line 55 "host_requirements.y" + char * val_str; int val_int; float val_float; -} -/* Line 1489 of yacc.c. */ + + + +/* Line 1676 of yacc.c */ #line 65 "host_requirements.hh" - YYSTYPE; +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif @@ -84,3 +84,4 @@ typedef struct YYLTYPE #endif + diff --git a/src/template/template_parser.c b/src/template/template_parser.c index 0324ec740b..dbb833e5d5 100644 --- a/src/template/template_parser.c +++ b/src/template/template_parser.c @@ -28,7 +28,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -211,13 +211,6 @@ extern FILE *template_in, *template_out; #define unput(c) yyunput( c, (yytext_ptr) ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -557,7 +550,7 @@ char *template_text; llocp->first_column = llocp->last_column; \ llocp->last_column += template_leng; -#line 561 "template_parser.c" +#line 554 "template_parser.c" #define INITIAL 0 #define VALUE 1 @@ -576,6 +569,35 @@ char *template_text; static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int template_lex_destroy (void ); + +int template_get_debug (void ); + +void template_set_debug (int debug_flag ); + +YY_EXTRA_TYPE template_get_extra (void ); + +void template_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *template_get_in (void ); + +void template_set_in (FILE * in_str ); + +FILE *template_get_out (void ); + +void template_set_out (FILE * out_str ); + +int template_get_leng (void ); + +char *template_get_text (void ); + +int template_get_lineno (void ); + +void template_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -715,7 +737,7 @@ YY_DECL /* ------------------------------------------------------------------------- */ /* Comments (lines with an starting #), and empty lines */ /* ------------------------------------------------------------------------- */ -#line 719 "template_parser.c" +#line 741 "template_parser.c" if ( !(yy_init) ) { @@ -891,7 +913,7 @@ YY_RULE_SETUP #line 85 "template_parser.l" ECHO; YY_BREAK -#line 895 "template_parser.c" +#line 917 "template_parser.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(VALUE): yyterminate(); diff --git a/src/template/template_syntax.cc b/src/template/template_syntax.cc index 2afa9c479a..8ff5909a72 100644 --- a/src/template/template_syntax.cc +++ b/src/template/template_syntax.cc @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,47 +54,28 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 1 /* Substitute the variable and function names. */ -#define yyparse template_parse -#define yylex template_lex -#define yyerror template_error -#define yylval template_lval -#define yychar template_char -#define yydebug template_debug -#define yynerrs template_nerrs -#define yylloc template_lloc - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - EQUAL = 258, - COMMA = 259, - OBRACKET = 260, - CBRACKET = 261, - EQUAL_EMPTY = 262, - STRING = 263, - VARIABLE = 264 - }; -#endif -/* Tokens. */ -#define EQUAL 258 -#define COMMA 259 -#define OBRACKET 260 -#define CBRACKET 261 -#define EQUAL_EMPTY 262 -#define STRING 263 -#define VARIABLE 264 - - - +#define yyparse template_parse +#define yylex template_lex +#define yyerror template_error +#define yylval template_lval +#define yychar template_char +#define yydebug template_debug +#define yynerrs template_nerrs +#define yylloc template_lloc /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 18 "template_syntax.y" #include @@ -128,6 +108,9 @@ int template_parse(Template * tmpl, char ** errmsg); static string& unescape (string &str); +/* Line 189 of yacc.c */ +#line 113 "template_syntax.cc" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -146,19 +129,43 @@ static string& unescape (string &str); # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + EQUAL = 258, + COMMA = 259, + OBRACKET = 260, + CBRACKET = 261, + EQUAL_EMPTY = 262, + STRING = 263, + VARIABLE = 264 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 52 "template_syntax.y" { + +/* Line 214 of yacc.c */ +#line 52 "template_syntax.y" + char * val_str; void * val_attr; -} -/* Line 187 of yacc.c. */ -#line 158 "template_syntax.cc" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 165 "template_syntax.cc" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED @@ -178,8 +185,8 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 183 "template_syntax.cc" +/* Line 264 of yacc.c */ +#line 190 "template_syntax.cc" #ifdef short # undef short @@ -254,14 +261,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -343,9 +350,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - YYLTYPE yyls; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ @@ -380,12 +387,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -750,17 +757,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, tmpl, error_msg) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -797,11 +807,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, tmpl, error_msg) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , tmpl, error_msg); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1087,10 +1097,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, tmpl, error_msg) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1109,10 +1117,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1137,24 +1144,59 @@ yyparse (tmpl, error_msg) #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc; - int yystate; + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1162,63 +1204,37 @@ YYLTYPE yylloc; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; yylsp = yyls; + #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; + yylloc.first_column = yylloc.last_column = 1; #endif goto yysetstate; @@ -1257,6 +1273,7 @@ YYLTYPE yylloc; &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; @@ -1278,9 +1295,9 @@ YYLTYPE yylloc; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - YYSTACK_RELOCATE (yyls); + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1301,6 +1318,9 @@ YYLTYPE yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1309,16 +1329,16 @@ YYLTYPE yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1350,20 +1370,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1404,6 +1420,8 @@ yyreduce: switch (yyn) { case 4: + +/* Line 1455 of yacc.c */ #line 77 "template_syntax.y" { Attribute * pattr; @@ -1420,6 +1438,8 @@ yyreduce: break; case 5: + +/* Line 1455 of yacc.c */ #line 90 "template_syntax.y" { Attribute * pattr; @@ -1437,6 +1457,8 @@ yyreduce: break; case 6: + +/* Line 1455 of yacc.c */ #line 104 "template_syntax.y" { Attribute * pattr; @@ -1452,6 +1474,8 @@ yyreduce: break; case 7: + +/* Line 1455 of yacc.c */ #line 118 "template_syntax.y" { map* vattr; @@ -1471,6 +1495,8 @@ yyreduce: break; case 8: + +/* Line 1455 of yacc.c */ #line 134 "template_syntax.y" { string name((yyvsp[(3) - (5)].val_str)); @@ -1490,8 +1516,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1495 "template_syntax.cc" + +/* Line 1455 of yacc.c */ +#line 1522 "template_syntax.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1567,7 +1594,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1584,7 +1611,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1642,14 +1669,11 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; @@ -1674,7 +1698,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1685,7 +1709,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc, tmpl, error_msg); /* Do not reclaim the symbols of the rule which action triggered @@ -1711,6 +1735,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 150 "template_syntax.y" diff --git a/src/template/template_syntax.h b/src/template/template_syntax.h index a2aeba6e7d..29e534b4d2 100644 --- a/src/template/template_syntax.h +++ b/src/template/template_syntax.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -48,31 +48,27 @@ VARIABLE = 264 }; #endif -/* Tokens. */ -#define EQUAL 258 -#define COMMA 259 -#define OBRACKET 260 -#define CBRACKET 261 -#define EQUAL_EMPTY 262 -#define STRING 263 -#define VARIABLE 264 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 52 "template_syntax.y" { + +/* Line 1676 of yacc.c */ +#line 52 "template_syntax.y" + char * val_str; void * val_attr; -} -/* Line 1489 of yacc.c. */ -#line 72 "template_syntax.hh" - YYSTYPE; + + + +/* Line 1676 of yacc.c */ +#line 68 "template_syntax.hh" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif @@ -91,3 +87,4 @@ typedef struct YYLTYPE #endif + diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 4714c3f95a..062d9b15e0 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -313,6 +313,26 @@ int VirtualMachine::insert(SqliteDB * db) goto error_leases; } + // ------------------------------------------------------------------------ + // Parse the context & requirements + // ------------------------------------------------------------------------ + + rc = parse_context(); + + if ( rc != 0 ) + { + goto error_context; + } + + rc = parse_requirements(); + + if ( rc != 0 ) + { + goto error_requirements; + } + + parse_graphics(); + // ------------------------------------------------------------------------ // Insert the template first, so we get a valid template ID. Then the VM // ------------------------------------------------------------------------ @@ -347,6 +367,162 @@ error_leases: Nebula::log("ONE",Log::ERROR, "Could not get network lease for VM"); release_network_leases(); return -1; + +error_context: + Nebula::log("ONE",Log::ERROR, "Could not parse CONTEXT for VM"); + release_network_leases(); + return -1; + +error_requirements: + Nebula::log("ONE",Log::ERROR, "Could not parse REQUIREMENTS for VM"); + release_network_leases(); + return -1; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachine::parse_context() +{ + int rc, num; + + vector array_context; + VectorAttribute * context; + + string * str; + string parsed; + + num = vm_template.remove("CONTEXT", array_context); + + if ( num == 0 ) + { + return 0; + } + + context = dynamic_cast(array_context[0]); + + if ( context == 0 ) + { + Nebula::log("ONE",Log::ERROR, "Wrong format for CONTEXT attribute"); + return -1; + } + + str = context->marshall(" @^_^@ "); + + if (str == 0) + { + Nebula::log("ONE",Log::ERROR, "Can not marshall CONTEXT"); + return -1; + } + + rc = parse_template_attribute(*str,parsed); + + if ( rc == 0 ) + { + VectorAttribute * context_parsed; + + context_parsed = new VectorAttribute("CONTEXT"); + context_parsed->unmarshall(parsed," @^_^@ "); + + vm_template.set(context_parsed); + } + + /* --- Delete old context attributes --- */ + + for (int i = 0; i < num ; i++) + { + if (array_context[i] != 0) + { + delete array_context[i]; + } + } + + return rc; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +void VirtualMachine::parse_graphics() +{ + int num; + + vector array_graphics; + VectorAttribute * graphics; + + num = vm_template.get("GRAPHICS", array_graphics); + + if ( num == 0 ) + { + return; + } + + graphics = dynamic_cast(array_graphics[0]); + + if ( graphics == 0 ) + { + return; + } + + string port = graphics->vector_value("PORT"); + + if ( port.empty() ) + { + ostringstream oss; + + oss << ( 5900 + oid ); + graphics->replace("PORT", oss.str()); + } +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int VirtualMachine::parse_requirements() +{ + int rc, num; + + vector array_reqs; + SingleAttribute * reqs; + + string parsed; + + num = vm_template.remove("REQUIREMENTS", array_reqs); + + if ( num == 0 ) + { + return 0; + } + + reqs = dynamic_cast(array_reqs[0]); + + if ( reqs == 0 ) + { + Nebula::log("ONE",Log::ERROR,"Wrong format for REQUIREMENTS attribute"); + return -1; + } + + rc = parse_template_attribute(reqs->value(),parsed); + + if ( rc == 0 ) + { + SingleAttribute * reqs_parsed; + + reqs_parsed = new SingleAttribute("REQUIREMENTS",parsed); + vm_template.set(reqs_parsed); + } + + /* --- Delete old requirements attributes --- */ + + for (int i = 0; i < num ; i++) + { + if (array_reqs[i] != 0) + { + delete array_reqs[i]; + } + } + + return rc; } /* -------------------------------------------------------------------------- */ @@ -565,26 +741,26 @@ void VirtualMachine::cp_history() void VirtualMachine::cp_previous_history() { - History * htmp; + History * htmp; - if ( previous_history == 0 || history == 0) - { - return; - } + if ( previous_history == 0 || history == 0) + { + return; + } - htmp = new History(oid, - history->seq + 1, - previous_history->hid, - previous_history->hostname, - previous_history->vm_dir, - previous_history->vmm_mad_name, - previous_history->tm_mad_name); + htmp = new History(oid, + history->seq + 1, + previous_history->hid, + previous_history->hostname, + previous_history->vm_dir, + previous_history->vmm_mad_name, + previous_history->tm_mad_name); - delete previous_history; + delete previous_history; - previous_history = history; + previous_history = history; - history = htmp; + history = htmp; } /* -------------------------------------------------------------------------- */ @@ -834,28 +1010,6 @@ int VirtualMachine::generate_context(string &files) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int VirtualMachine::parse_template_attribute(const string& attribute, - string& parsed) -{ - int rc; - char * err = 0; - - rc = parse_attribute(this,-1,attribute,parsed,&err); - - if ( rc != 0 && err != 0 ) - { - ostringstream oss; - - oss << "Error parsing: " << attribute << ". " << err; - log("VM",Log::ERROR,oss); - } - - return rc; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - pthread_mutex_t VirtualMachine::lex_mutex = PTHREAD_MUTEX_INITIALIZER; extern "C" @@ -863,7 +1017,6 @@ extern "C" typedef struct yy_buffer_state * YY_BUFFER_STATE; int vm_var_parse (VirtualMachine * vm, - int vm_id, ostringstream * parsed, char ** errmsg); @@ -876,18 +1029,14 @@ extern "C" /* -------------------------------------------------------------------------- */ -int VirtualMachine::parse_attribute(VirtualMachine * vm, - int vm_id, - const string& attribute, - string& parsed, - char ** error_msg) +int VirtualMachine::parse_template_attribute(const string& attribute, + string& parsed) { YY_BUFFER_STATE str_buffer = 0; const char * str; int rc; ostringstream oss_parsed; - - *error_msg = 0; + char * error_msg = 0; pthread_mutex_lock(&lex_mutex); @@ -899,20 +1048,30 @@ int VirtualMachine::parse_attribute(VirtualMachine * vm, goto error_yy; } - rc = vm_var_parse(vm,vm_id,&oss_parsed,error_msg); + rc = vm_var_parse(this,&oss_parsed,&error_msg); vm_var__delete_buffer(str_buffer); vm_var_lex_destroy(); pthread_mutex_unlock(&lex_mutex); + + if ( rc != 0 && error_msg != 0 ) + { + ostringstream oss; + oss << "Error parsing: " << attribute << ". " << error_msg; + log("VM",Log::ERROR,oss); + + free(error_msg); + } + parsed = oss_parsed.str(); return rc; error_yy: - *error_msg=strdup("Error setting scan buffer"); + log("VM",Log::ERROR,"Error setting scan buffer"); pthread_mutex_unlock(&lex_mutex); return -1; } @@ -922,10 +1081,10 @@ error_yy: ostream& operator<<(ostream& os, const VirtualMachine& vm) { - string vm_str; - - os << vm.to_xml(vm_str); - + string vm_str; + + os << vm.to_xml(vm_str); + return os; }; @@ -933,48 +1092,50 @@ ostream& operator<<(ostream& os, const VirtualMachine& vm) string& VirtualMachine::to_xml(string& xml) const { - string template_xml; + + string template_xml; string history_xml; - ostringstream oss; - - oss << "" - << "" << oid << "" - << "" << uid << "" - << "" << name << "" - << "" << last_poll << "" - << "" << state << "" - << "" << lcm_state << "" - << "" << stime << "" - << "" << etime << "" - << "" << deploy_id << "" - << "" << memory << "" - << "" << cpu << "" - << "" << net_tx << "" - << "" << net_rx << "" - << vm_template.to_xml(template_xml); + ostringstream oss; + + oss << "" + << "" << oid << "" + << "" << uid << "" + << "" << name << "" + << "" << last_poll << "" + << "" << state << "" + << "" << lcm_state << "" + << "" << stime << "" + << "" << etime << "" + << "" << deploy_id << "" + << "" << memory << "" + << "" << cpu << "" + << "" << net_tx << "" + << "" << net_rx << "" + << vm_template.to_xml(template_xml); if ( hasHistory() ) { oss << history->to_xml(history_xml); } - oss << ""; - - xml = oss.str(); - - return xml; + + oss << ""; + + xml = oss.str(); + + return xml; } /* -------------------------------------------------------------------------- */ string& VirtualMachine::to_str(string& str) const { - string template_str; + string template_str; string history_str; - ostringstream oss; - - oss<< "ID : " << oid << endl + ostringstream oss; + + oss<< "ID : " << oid << endl << "UID : " << uid << endl << "NAME : " << name << endl << "STATE : " << state << endl @@ -994,9 +1155,9 @@ string& VirtualMachine::to_str(string& str) const oss << "Last History Record" << endl << history->to_str(history_str); } - str = oss.str(); + str = oss.str(); - return str; + return str; } /* -------------------------------------------------------------------------- */ diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index ee24bd85e3..6f5ee76f06 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -158,10 +158,7 @@ int VirtualMachinePool::allocate ( string name; char * error_msg; - int rc, num_context, num_reqs; - - vector context; - vector reqs; + int rc; // ------------------------------------------------------------------------ // Build a new Virtual Machine object @@ -180,7 +177,7 @@ int VirtualMachinePool::allocate ( vm->uid = uid; // ------------------------------------------------------------------------ - // Parse template and keep CONTEXT and REQUIREMENTS apart + // Parse template // ------------------------------------------------------------------------ rc = vm->vm_template.parse(stemplate,&error_msg); @@ -195,9 +192,6 @@ int VirtualMachinePool::allocate ( return -2; } - num_context = vm->vm_template.remove("CONTEXT",context); - num_reqs = vm->vm_template.remove("REQUIREMENTS",reqs); - // ------------------------------------------------------------------------ // Insert the Object in the pool // ------------------------------------------------------------------------ @@ -209,40 +203,6 @@ int VirtualMachinePool::allocate ( return -1; } - // ------------------------------------------------------------------------ - // Insert parsed context in the VM template and clean-up - // ------------------------------------------------------------------------ - - if ( num_context > 0) - { - generate_context(*oid,context[0]); - - for (int i = 0; i < num_context ; i++) - { - if (context[i] != 0) - { - delete context[i]; - } - } - } - - // ------------------------------------------------------------------------ - // Parse the Requirements - // ------------------------------------------------------------------------ - - if ( num_reqs > 0 ) - { - generate_requirements(*oid,reqs[0]); - - for (int i = 0; i < num_reqs ; i++) - { - if (reqs[i] != 0) - { - delete reqs[i]; - } - } - } - return 0; } @@ -282,126 +242,3 @@ int VirtualMachinePool::get_pending( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ - -void VirtualMachinePool::generate_context(int vm_id, Attribute * attr) -{ - VirtualMachine * vm; - VectorAttribute * context_parsed; - VectorAttribute * context; - - string * str; - string parsed; - - int rc; - - char * error_msg; - - context = dynamic_cast(attr); - - if (context == 0) - { - return; - } - - str = context->marshall(" @^_^@ "); - - if (str == 0) - { - return; - } - - rc = VirtualMachine::parse_template_attribute(vm_id,*str,parsed,&error_msg); - - if ( rc != 0 ) - { - if (error_msg != 0) - { - ostringstream oss; - - oss << error_msg << ": " << *str; - free(error_msg); - - Nebula::log("ONE", Log::ERROR, oss); - } - - delete str; - - return; - } - - delete str; - - context_parsed = new VectorAttribute("CONTEXT"); - context_parsed->unmarshall(parsed," @^_^@ "); - - vm = get(vm_id,true); - - if ( vm == 0 ) - { - delete context_parsed; - return; - } - - if ( vm->insert_template_attribute(db,context_parsed) != 0 ) - { - delete context_parsed; - } - - vm->unlock(); -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void VirtualMachinePool::generate_requirements(int vm_id, Attribute * attr) -{ - SingleAttribute * reqs; - string parsed; - char * error_msg; - int rc; - - SingleAttribute * reqs_parsed; - VirtualMachine * vm; - - reqs = dynamic_cast(attr); - - if (reqs == 0) - { - return; - } - - rc = VirtualMachine::parse_template_attribute(vm_id,reqs->value(), - parsed,&error_msg); - - if ( rc != 0 ) - { - if (error_msg != 0) - { - ostringstream oss; - - oss << error_msg << ": " << reqs->value(); - free(error_msg); - - Nebula::log("ONE", Log::ERROR, oss); - } - - return; - } - - reqs_parsed = new SingleAttribute("REQUIREMENTS",parsed); - - vm = get(vm_id,true); - - if ( vm == 0 ) - { - delete reqs_parsed; - return; - } - - if ( vm->insert_template_attribute(db,reqs_parsed) != 0 ) - { - delete reqs_parsed; - } - - vm->unlock(); -} diff --git a/src/vm/vm_var_parser.c b/src/vm/vm_var_parser.c index 915b73edf9..8fc12989e1 100644 --- a/src/vm/vm_var_parser.c +++ b/src/vm/vm_var_parser.c @@ -28,7 +28,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -211,13 +211,6 @@ extern FILE *vm_var_in, *vm_var_out; #define unput(c) yyunput( c, (yytext_ptr) ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -399,8 +392,8 @@ static void yy_fatal_error (yyconst char msg[] ); *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 12 -#define YY_END_OF_BUFFER 13 +#define YY_NUM_RULES 11 +#define YY_END_OF_BUFFER 12 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -408,12 +401,11 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[33] = +static yyconst flex_int16_t yy_accept[30] = { 0, - 0, 0, 0, 0, 13, 11, 1, 10, 10, 12, - 10, 9, 3, 7, 2, 7, 4, 5, 11, 0, - 3, 2, 5, 0, 8, 3, 6, 7, 7, 2, - 4, 0 + 0, 0, 0, 0, 12, 10, 1, 9, 9, 11, + 9, 8, 3, 6, 2, 4, 5, 10, 0, 3, + 2, 5, 0, 7, 3, 6, 2, 4, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -422,16 +414,16 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 4, 1, 5, 1, 1, 1, 1, - 1, 1, 1, 6, 1, 7, 1, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, - 9, 1, 1, 1, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 11, 1, 12, 1, 10, 1, 10, 10, 10, 10, + 1, 1, 1, 6, 1, 1, 1, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, + 8, 1, 1, 1, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 9, 1, 10, 1, 7, 1, 7, 7, 7, 7, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -448,52 +440,49 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[13] = +static yyconst flex_int32_t yy_meta[11] = { 0, - 1, 1, 1, 1, 2, 1, 1, 3, 1, 3, - 1, 1 + 1, 1, 1, 1, 2, 1, 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[37] = +static yyconst flex_int16_t yy_base[33] = { 0, - 36, 35, 0, 0, 39, 0, 42, 42, 11, 42, - 34, 42, 35, 17, 30, 0, 24, 42, 0, 0, - 20, 19, 42, 15, 42, 16, 42, 0, 0, 14, - 13, 42, 27, 30, 33, 11 + 29, 28, 0, 0, 32, 0, 35, 35, 9, 35, + 27, 35, 28, 22, 26, 25, 35, 0, 0, 24, + 23, 35, 20, 35, 16, 9, 12, 11, 35, 19, + 11, 21 } ; -static yyconst flex_int16_t yy_def[37] = +static yyconst flex_int16_t yy_def[33] = { 0, - 33, 33, 32, 3, 32, 34, 32, 32, 32, 32, - 35, 32, 32, 32, 32, 36, 32, 32, 34, 9, - 32, 32, 32, 35, 32, 32, 32, 14, 36, 32, - 32, 0, 32, 32, 32, 32 + 30, 30, 29, 3, 29, 31, 29, 29, 29, 29, + 32, 29, 29, 29, 29, 29, 29, 31, 9, 29, + 29, 29, 32, 29, 29, 29, 29, 29, 0, 29, + 29, 29 } ; -static yyconst flex_int16_t yy_nxt[55] = +static yyconst flex_int16_t yy_nxt[46] = { 0, - 8, 9, 10, 11, 12, 13, 8, 14, 15, 16, - 17, 18, 20, 29, 31, 30, 21, 26, 25, 22, - 30, 26, 23, 27, 28, 31, 29, 6, 6, 6, - 19, 30, 19, 24, 24, 24, 26, 25, 32, 7, - 7, 5, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32 + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 19, 18, 28, 27, 20, 26, 21, 25, 22, 6, + 6, 23, 23, 24, 27, 25, 28, 27, 26, 25, + 24, 29, 7, 7, 5, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29 } ; -static yyconst flex_int16_t yy_chk[55] = +static yyconst flex_int16_t yy_chk[46] = { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 9, 36, 31, 30, 9, 26, 24, 9, - 22, 21, 9, 14, 14, 17, 14, 33, 33, 33, - 34, 15, 34, 35, 35, 35, 13, 11, 5, 2, - 1, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32 + 9, 31, 28, 27, 9, 26, 9, 25, 9, 30, + 30, 32, 32, 23, 21, 20, 16, 15, 14, 13, + 11, 5, 2, 1, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[13] = +static yyconst flex_int32_t yy_rule_can_match_eol[12] = { 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, }; +0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, }; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; @@ -540,7 +529,7 @@ char *vm_var_text; llocp->first_column = llocp->last_column; \ llocp->last_column += vm_var_leng; -#line 544 "vm_var_parser.c" +#line 533 "vm_var_parser.c" #define INITIAL 0 #define VAR 1 @@ -559,6 +548,35 @@ char *vm_var_text; static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int vm_var_lex_destroy (void ); + +int vm_var_get_debug (void ); + +void vm_var_set_debug (int debug_flag ); + +YY_EXTRA_TYPE vm_var_get_extra (void ); + +void vm_var_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *vm_var_get_in (void ); + +void vm_var_set_in (FILE * in_str ); + +FILE *vm_var_get_out (void ); + +void vm_var_set_out (FILE * out_str ); + +int vm_var_get_leng (void ); + +char *vm_var_get_text (void ); + +int vm_var_get_lineno (void ); + +void vm_var_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -703,7 +721,7 @@ YY_DECL /* $NUM.CONTEXT_VARIABLE */ /* ------------------------------------------------------------------------- */ -#line 707 "vm_var_parser.c" +#line 725 "vm_var_parser.c" if ( !(yy_init) ) { @@ -756,13 +774,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 33 ) + if ( yy_current_state >= 30 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 42 ); + while ( yy_base[yy_current_state] != 35 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -824,33 +842,26 @@ YY_RULE_SETUP case 6: YY_RULE_SETUP #line 56 "vm_var_parser.l" -{ vm_var_text[vm_var_leng-1] = '\0'; - lvalp->val_int = atoi(vm_var_text); - return INTEGER;} - YY_BREAK -case 7: -YY_RULE_SETUP -#line 59 "vm_var_parser.l" { lvalp->val_str = strdup(vm_var_text); return VARIABLE;} YY_BREAK -case 8: -/* rule 8 can match eol */ +case 7: +/* rule 7 can match eol */ YY_RULE_SETUP -#line 61 "vm_var_parser.l" +#line 59 "vm_var_parser.l" { lvalp->val_str = strdup(vm_var_text+1); lvalp->val_str[vm_var_leng-2] = '\0'; return STRING;} YY_BREAK -case 9: +case 8: YY_RULE_SETUP -#line 65 "vm_var_parser.l" +#line 63 "vm_var_parser.l" { lvalp->val_char = '\0'; return EOA;} YY_BREAK -case 10: +case 9: YY_RULE_SETUP -#line 67 "vm_var_parser.l" +#line 66 "vm_var_parser.l" { lvalp->val_char = *vm_var_text; BEGIN(INITIAL); return EOA;} @@ -864,18 +875,18 @@ case YY_STATE_EOF(VAR): /* ------------------------------------------------------------------------- */ /* Just copy the string verbatim till we find a variable (starts with $) */ /* ------------------------------------------------------------------------- */ -case 11: -/* rule 11 can match eol */ +case 10: +/* rule 10 can match eol */ YY_RULE_SETUP #line 78 "vm_var_parser.l" { lvalp->val_str = strdup(vm_var_text); return RSTRING;} YY_BREAK -case 12: +case 11: YY_RULE_SETUP #line 80 "vm_var_parser.l" ECHO; YY_BREAK -#line 879 "vm_var_parser.c" +#line 890 "vm_var_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1167,7 +1178,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 33 ) + if ( yy_current_state >= 30 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1195,11 +1206,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 33 ) + if ( yy_current_state >= 30 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 32); + yy_is_jam = (yy_current_state == 29); return yy_is_jam ? 0 : yy_current_state; } diff --git a/src/vm/vm_var_parser.l b/src/vm/vm_var_parser.l index 22ab2725e7..9b6d2d1343 100644 --- a/src/vm/vm_var_parser.l +++ b/src/vm/vm_var_parser.l @@ -53,20 +53,20 @@ \[[[:blank:]]* { return OBRACKET;} [[:blank:]]*\] { return CBRACKET;} -[[:digit:]]+\. { yytext[yyleng-1] = '\0'; - lvalp->val_int = atoi(yytext); - return INTEGER;} [[:alnum:]_]+ { lvalp->val_str = strdup(yytext); return VARIABLE;} + \"[^\"]*\" { lvalp->val_str = strdup(yytext+1); lvalp->val_str[yyleng-2] = '\0'; return STRING;} \$ { lvalp->val_char = '\0'; return EOA;} + . { lvalp->val_char = *yytext; BEGIN(INITIAL); return EOA;} + <> { lvalp->val_char = '\0'; BEGIN(INITIAL); return EOA;} diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index 05608c0f45..fdbe89b0f6 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,51 +54,28 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 1 /* Substitute the variable and function names. */ -#define yyparse vm_var_parse -#define yylex vm_var_lex -#define yyerror vm_var_error -#define yylval vm_var_lval -#define yychar vm_var_char -#define yydebug vm_var_debug -#define yynerrs vm_var_nerrs -#define yylloc vm_var_lloc - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - EQUAL = 258, - COMMA = 259, - OBRACKET = 260, - CBRACKET = 261, - EOA = 262, - STRING = 263, - VARIABLE = 264, - RSTRING = 265, - INTEGER = 266 - }; -#endif -/* Tokens. */ -#define EQUAL 258 -#define COMMA 259 -#define OBRACKET 260 -#define CBRACKET 261 -#define EOA 262 -#define STRING 263 -#define VARIABLE 264 -#define RSTRING 265 -#define INTEGER 266 - - - +#define yyparse vm_var_parse +#define yylex vm_var_lex +#define yyerror vm_var_error +#define yylval vm_var_lval +#define yychar vm_var_char +#define yydebug vm_var_debug +#define yynerrs vm_var_nerrs +#define yylloc vm_var_lloc /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 18 "vm_var_syntax.y" #include @@ -124,8 +100,7 @@ extern "C" { void vm_var_error( YYLTYPE * llocp, - VirtualMachine * vm, - int vm_id, + VirtualMachine * vm, ostringstream * parsed, char ** errmsg, const char * str); @@ -133,7 +108,6 @@ void vm_var_error( int vm_var_lex (YYSTYPE *lvalp, YYLTYPE *llocp); int vm_var_parse (VirtualMachine * vm, - int vm_id, ostringstream * parsed, char ** errmsg); } @@ -142,71 +116,37 @@ int vm_var_parse (VirtualMachine * vm, /* -------------------------------------------------------------------------- */ void insert_single(VirtualMachine * vm, - int vm_id, ostringstream& parsed, const string& name) { - VirtualMachine * tvm = vm; string value = ""; - - if ( vm == 0 ) - { - Nebula& nd = Nebula::instance(); - tvm = nd.get_vmpool()->get(vm_id,true); - } - - if ( tvm == 0 ) - { - return; - } - - tvm->get_template_attribute(name.c_str(),value); + vm->get_template_attribute(name.c_str(),value); parsed << value; - - if ( vm == 0 ) - { - tvm->unlock(); - } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void insert_vector(VirtualMachine * vm, - int vm_id, ostringstream& parsed, const string& name, const string& vname, const string& vvar, const string& vval) -{ - VirtualMachine * tvm = vm; - +{ vector values; const VectorAttribute * vattr = 0; int num; string value = ""; - - if ( vm == 0 ) - { - Nebula& nd = Nebula::instance(); - - tvm = nd.get_vmpool()->get(vm_id,true); - } - - if ( tvm == 0 ) + + if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 ) { return; } - - if ( ( num = tvm->get_template_attribute(name.c_str(),values) ) <= 0 ) - { - goto error_name; - } if ( vvar.empty() ) { @@ -214,7 +154,7 @@ void insert_vector(VirtualMachine * vm, } else { - const VectorAttribute * tmp = 0; + const VectorAttribute * tmp = 0; for (int i=0 ; i < num ; i++) { @@ -232,12 +172,6 @@ void insert_vector(VirtualMachine * vm, { parsed << vattr->vector_value(vname.c_str()); } - -error_name: - if ( vm == 0 ) - { - tvm->unlock(); - } } /* -------------------------------------------------------------------------- */ @@ -245,6 +179,9 @@ error_name: +/* Line 189 of yacc.c */ +#line 184 "vm_var_syntax.cc" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -263,20 +200,46 @@ error_name: # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + EQUAL = 258, + COMMA = 259, + OBRACKET = 260, + CBRACKET = 261, + EOA = 262, + STRING = 263, + VARIABLE = 264, + RSTRING = 265, + INTEGER = 266 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 167 "vm_var_syntax.y" { + +/* Line 214 of yacc.c */ +#line 124 "vm_var_syntax.y" + char * val_str; int val_int; char val_char; -} -/* Line 187 of yacc.c. */ -#line 276 "vm_var_syntax.cc" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 239 "vm_var_syntax.cc" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED @@ -296,8 +259,8 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 301 "vm_var_syntax.cc" +/* Line 264 of yacc.c */ +#line 264 "vm_var_syntax.cc" #ifdef short # undef short @@ -372,14 +335,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -461,9 +424,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - YYLTYPE yyls; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ @@ -498,12 +461,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -512,18 +475,18 @@ union yyalloc #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 9 +#define YYFINAL 7 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 20 +#define YYLAST 18 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 12 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 3 /* YYNRULES -- Number of rules. */ -#define YYNRULES 8 +#define YYNRULES 7 /* YYNRULES -- Number of states. */ -#define YYNSTATES 21 +#define YYNSTATES 18 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -569,7 +532,7 @@ static const yytype_uint8 yytranslate[] = YYRHS. */ static const yytype_uint8 yyprhs[] = { - 0, 0, 3, 5, 8, 10, 13, 19, 29 + 0, 0, 3, 5, 8, 10, 13, 19 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -577,14 +540,13 @@ static const yytype_int8 yyrhs[] = { 13, 0, -1, 14, -1, 13, 14, -1, 10, -1, 9, 7, -1, 9, 5, 9, 6, 7, -1, 9, - 5, 9, 4, 9, 3, 8, 6, 7, -1, 11, - 9, 7, -1 + 5, 9, 4, 9, 3, 8, 6, 7, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +static const yytype_uint8 yyrline[] = { - 0, 191, 191, 192, 195, 200, 215, 233, 256 + 0, 148, 148, 149, 152, 157, 172, 190 }; #endif @@ -612,13 +574,13 @@ static const yytype_uint16 yytoknum[] = /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 12, 13, 13, 14, 14, 14, 14, 14 + 0, 12, 13, 13, 14, 14, 14, 14 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 1, 2, 1, 2, 5, 9, 3 + 0, 2, 1, 2, 1, 2, 5, 9 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -626,31 +588,29 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 0, 4, 0, 0, 2, 0, 5, 0, 1, - 3, 0, 8, 0, 0, 0, 6, 0, 0, 0, - 7 + 0, 0, 4, 0, 2, 0, 5, 1, 3, 0, + 0, 0, 0, 6, 0, 0, 0, 7 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 4, 5 + -1, 3, 4 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -9 +#define YYPACT_NINF -5 static const yytype_int8 yypact[] = { - -8, -1, -9, 3, 0, -9, 4, -9, 7, -9, - -9, 1, -9, 6, 9, 5, -9, 10, 11, 12, - -9 + -3, -4, -5, 0, -5, -1, -5, -5, -5, -2, + 2, 5, 10, -5, 6, 9, 11, -5 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -9, -9, 16 + -5, -5, 13 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -660,25 +620,22 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 9, 1, 2, 3, 6, 13, 7, 14, 17, 1, - 2, 3, 8, 11, 12, 15, 16, 19, 18, 20, - 10 + 7, 5, 10, 6, 11, 0, 1, 2, 9, 1, + 2, 12, 13, 14, 15, 16, 8, 0, 17 }; -static const yytype_uint8 yycheck[] = +static const yytype_int8 yycheck[] = { - 0, 9, 10, 11, 5, 4, 7, 6, 3, 9, - 10, 11, 9, 9, 7, 9, 7, 6, 8, 7, - 4 + 0, 5, 4, 7, 6, -1, 9, 10, 9, 9, + 10, 9, 7, 3, 8, 6, 3, -1, 7 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 9, 10, 11, 13, 14, 5, 7, 9, 0, - 14, 9, 7, 4, 6, 9, 7, 3, 8, 6, - 7 + 0, 9, 10, 13, 14, 5, 7, 0, 14, 9, + 4, 6, 9, 7, 3, 8, 6, 7 }; #define yyerrok (yyerrstatus = 0) @@ -711,7 +668,7 @@ do \ } \ else \ { \ - yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("syntax error: cannot back up")); \ + yyerror (&yylloc, vm, parsed, errmsg, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) @@ -791,7 +748,7 @@ do { \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value, Location, vm, vm_id, parsed, errmsg); \ + Type, Value, Location, vm, parsed, errmsg); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) @@ -805,16 +762,15 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, ostringstream * parsed, char ** errmsg) #else static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg) +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, parsed, errmsg) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; VirtualMachine * vm; - int vm_id; ostringstream * parsed; char ** errmsg; #endif @@ -823,7 +779,6 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parse return; YYUSE (yylocationp); YYUSE (vm); - YYUSE (vm_id); YYUSE (parsed); YYUSE (errmsg); # ifdef YYPRINT @@ -847,16 +802,15 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parse #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, ostringstream * parsed, char ** errmsg) #else static void -yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg) +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, parsed, errmsg) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; YYLTYPE const * const yylocationp; VirtualMachine * vm; - int vm_id; ostringstream * parsed; char ** errmsg; #endif @@ -868,7 +822,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, err YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, parsed, errmsg); YYFPRINTF (yyoutput, ")"); } @@ -880,17 +834,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, err #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -908,15 +865,14 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, VirtualMachine * vm, ostringstream * parsed, char ** errmsg) #else static void -yy_reduce_print (yyvsp, yylsp, yyrule, vm, vm_id, parsed, errmsg) +yy_reduce_print (yyvsp, yylsp, yyrule, vm, parsed, errmsg) YYSTYPE *yyvsp; YYLTYPE *yylsp; int yyrule; VirtualMachine * vm; - int vm_id; ostringstream * parsed; char ** errmsg; #endif @@ -929,18 +885,18 @@ yy_reduce_print (yyvsp, yylsp, yyrule, vm, vm_id, parsed, errmsg) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) - , &(yylsp[(yyi + 1) - (yynrhs)]) , vm, vm_id, parsed, errmsg); - fprintf (stderr, "\n"); + , &(yylsp[(yyi + 1) - (yynrhs)]) , vm, parsed, errmsg); + YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, yylsp, Rule, vm, vm_id, parsed, errmsg); \ + yy_reduce_print (yyvsp, yylsp, Rule, vm, parsed, errmsg); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that @@ -1191,16 +1147,15 @@ yysyntax_error (char *yyresult, int yystate, int yychar) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, VirtualMachine * vm, ostringstream * parsed, char ** errmsg) #else static void -yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg) +yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, parsed, errmsg) const char *yymsg; int yytype; YYSTYPE *yyvaluep; YYLTYPE *yylocationp; VirtualMachine * vm; - int vm_id; ostringstream * parsed; char ** errmsg; #endif @@ -1208,7 +1163,6 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg) YYUSE (yyvaluep); YYUSE (yylocationp); YYUSE (vm); - YYUSE (vm_id); YYUSE (parsed); YYUSE (errmsg); @@ -1223,10 +1177,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1235,7 +1187,7 @@ int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg); +int yyparse (VirtualMachine * vm, ostringstream * parsed, char ** errmsg); #else int yyparse (); #endif @@ -1245,10 +1197,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1264,35 +1215,69 @@ yyparse (YYPARSE_PARAM) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int -yyparse (VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg) +yyparse (VirtualMachine * vm, ostringstream * parsed, char ** errmsg) #else int -yyparse (vm, vm_id, parsed, errmsg) +yyparse (vm, parsed, errmsg) VirtualMachine * vm; - int vm_id; ostringstream * parsed; char ** errmsg; #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc; - int yystate; + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1300,63 +1285,37 @@ YYLTYPE yylloc; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; yylsp = yyls; + #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; + yylloc.first_column = yylloc.last_column = 1; #endif goto yysetstate; @@ -1395,6 +1354,7 @@ YYLTYPE yylloc; &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; @@ -1416,9 +1376,9 @@ YYLTYPE yylloc; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - YYSTACK_RELOCATE (yyls); + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1439,6 +1399,9 @@ YYLTYPE yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1447,16 +1410,16 @@ YYLTYPE yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1488,20 +1451,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1542,7 +1501,9 @@ yyreduce: switch (yyn) { case 4: -#line 196 "vm_var_syntax.y" + +/* Line 1455 of yacc.c */ +#line 153 "vm_var_syntax.y" { (*parsed) << (yyvsp[(1) - (1)].val_str); free((yyvsp[(1) - (1)].val_str)); @@ -1550,13 +1511,15 @@ yyreduce: break; case 5: -#line 201 "vm_var_syntax.y" + +/* Line 1455 of yacc.c */ +#line 158 "vm_var_syntax.y" { string name((yyvsp[(1) - (2)].val_str)); VM_VAR_TO_UPPER(name); - insert_single(vm,vm_id,*parsed,name); + insert_single(vm,*parsed,name); if ( (yyvsp[(2) - (2)].val_char) != '\0' ) { @@ -1568,7 +1531,9 @@ yyreduce: break; case 6: -#line 216 "vm_var_syntax.y" + +/* Line 1455 of yacc.c */ +#line 173 "vm_var_syntax.y" { string name((yyvsp[(1) - (5)].val_str)); string vname((yyvsp[(3) - (5)].val_str)); @@ -1576,7 +1541,7 @@ yyreduce: VM_VAR_TO_UPPER(name); VM_VAR_TO_UPPER(vname); - insert_vector(vm,vm_id,*parsed,name,vname,"",""); + insert_vector(vm,*parsed,name,vname,"",""); if ( (yyvsp[(5) - (5)].val_char) != '\0' ) { @@ -1589,7 +1554,9 @@ yyreduce: break; case 7: -#line 234 "vm_var_syntax.y" + +/* Line 1455 of yacc.c */ +#line 191 "vm_var_syntax.y" { string name((yyvsp[(1) - (9)].val_str)); string vname((yyvsp[(3) - (9)].val_str)); @@ -1600,7 +1567,7 @@ yyreduce: VM_VAR_TO_UPPER(vname); VM_VAR_TO_UPPER(vvar); - insert_vector(vm,vm_id,*parsed,name,vname,vvar,vval); + insert_vector(vm,*parsed,name,vname,vvar,vval); if ( (yyvsp[(9) - (9)].val_char) != '\0' ) { @@ -1614,28 +1581,10 @@ yyreduce: ;} break; - case 8: -#line 257 "vm_var_syntax.y" - { - string name("CONTEXT"); - string vname((yyvsp[(2) - (3)].val_str)); - - VM_VAR_TO_UPPER(vname); - - insert_vector(0,(yyvsp[(1) - (3)].val_int),*parsed,name,vname,"",""); - - if ( (yyvsp[(3) - (3)].val_char) != '\0' ) - { - (*parsed) << (yyvsp[(3) - (3)].val_char); - } - - free((yyvsp[(2) - (3)].val_str)); - ;} - break; -/* Line 1267 of yacc.c. */ -#line 1639 "vm_var_syntax.cc" +/* Line 1455 of yacc.c */ +#line 1588 "vm_var_syntax.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1671,7 +1620,7 @@ yyerrlab: { ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("syntax error")); + yyerror (&yylloc, vm, parsed, errmsg, YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); @@ -1695,11 +1644,11 @@ yyerrlab: if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (&yylloc, vm, vm_id, parsed, errmsg, yymsg); + yyerror (&yylloc, vm, parsed, errmsg, yymsg); } else { - yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("syntax error")); + yyerror (&yylloc, vm, parsed, errmsg, YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } @@ -1711,7 +1660,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1723,12 +1672,12 @@ yyerrlab: else { yydestruct ("Error: discarding", - yytoken, &yylval, &yylloc, vm, vm_id, parsed, errmsg); + yytoken, &yylval, &yylloc, vm, parsed, errmsg); yychar = YYEMPTY; } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1780,20 +1729,17 @@ yyerrlab1: yyerror_range[0] = *yylsp; yydestruct ("Error: popping", - yystos[yystate], yyvsp, yylsp, vm, vm_id, parsed, errmsg); + yystos[yystate], yyvsp, yylsp, vm, parsed, errmsg); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; @@ -1818,20 +1764,20 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("memory exhausted")); + yyerror (&yylloc, vm, parsed, errmsg, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, vm, vm_id, parsed, errmsg); + yytoken, &yylval, &yylloc, vm, parsed, errmsg); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -1839,7 +1785,7 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, yylsp, vm, vm_id, parsed, errmsg); + yystos[*yyssp], yyvsp, yylsp, vm, parsed, errmsg); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1855,13 +1801,14 @@ yyreturn: } -#line 273 "vm_var_syntax.y" + +/* Line 1675 of yacc.c */ +#line 214 "vm_var_syntax.y" extern "C" void vm_var_error( YYLTYPE * llocp, VirtualMachine * vm, - int vm_id, ostringstream * parsed, char ** error_msg, const char * str) diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index d33fb79e0d..dc91f22220 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -50,34 +50,28 @@ INTEGER = 266 }; #endif -/* Tokens. */ -#define EQUAL 258 -#define COMMA 259 -#define OBRACKET 260 -#define CBRACKET 261 -#define EOA 262 -#define STRING 263 -#define VARIABLE 264 -#define RSTRING 265 -#define INTEGER 266 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 167 "vm_var_syntax.y" { + +/* Line 1676 of yacc.c */ +#line 124 "vm_var_syntax.y" + char * val_str; int val_int; char val_char; -} -/* Line 1489 of yacc.c. */ -#line 77 "vm_var_syntax.hh" - YYSTYPE; + + + +/* Line 1676 of yacc.c */ +#line 71 "vm_var_syntax.hh" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif @@ -96,3 +90,4 @@ typedef struct YYLTYPE #endif + diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index 49da9a261e..deb1dc9f96 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -38,8 +38,7 @@ extern "C" { void vm_var_error( YYLTYPE * llocp, - VirtualMachine * vm, - int vm_id, + VirtualMachine * vm, ostringstream * parsed, char ** errmsg, const char * str); @@ -47,7 +46,6 @@ void vm_var_error( int vm_var_lex (YYSTYPE *lvalp, YYLTYPE *llocp); int vm_var_parse (VirtualMachine * vm, - int vm_id, ostringstream * parsed, char ** errmsg); } @@ -56,71 +54,37 @@ int vm_var_parse (VirtualMachine * vm, /* -------------------------------------------------------------------------- */ void insert_single(VirtualMachine * vm, - int vm_id, ostringstream& parsed, const string& name) { - VirtualMachine * tvm = vm; string value = ""; - - if ( vm == 0 ) - { - Nebula& nd = Nebula::instance(); - tvm = nd.get_vmpool()->get(vm_id,true); - } - - if ( tvm == 0 ) - { - return; - } - - tvm->get_template_attribute(name.c_str(),value); + vm->get_template_attribute(name.c_str(),value); parsed << value; - - if ( vm == 0 ) - { - tvm->unlock(); - } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void insert_vector(VirtualMachine * vm, - int vm_id, ostringstream& parsed, const string& name, const string& vname, const string& vvar, const string& vval) -{ - VirtualMachine * tvm = vm; - +{ vector values; const VectorAttribute * vattr = 0; int num; string value = ""; - - if ( vm == 0 ) - { - Nebula& nd = Nebula::instance(); - - tvm = nd.get_vmpool()->get(vm_id,true); - } - - if ( tvm == 0 ) + + if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 ) { return; } - - if ( ( num = tvm->get_template_attribute(name.c_str(),values) ) <= 0 ) - { - goto error_name; - } if ( vvar.empty() ) { @@ -128,7 +92,7 @@ void insert_vector(VirtualMachine * vm, } else { - const VectorAttribute * tmp = 0; + const VectorAttribute * tmp = 0; for (int i=0 ; i < num ; i++) { @@ -146,12 +110,6 @@ void insert_vector(VirtualMachine * vm, { parsed << vattr->vector_value(vname.c_str()); } - -error_name: - if ( vm == 0 ) - { - tvm->unlock(); - } } /* -------------------------------------------------------------------------- */ @@ -160,7 +118,6 @@ error_name: %} %parse-param {VirtualMachine * vm} -%parse-param {int vm_id} %parse-param {ostringstream * parsed} %parse-param {char ** errmsg} @@ -203,7 +160,7 @@ vm_variable:RSTRING VM_VAR_TO_UPPER(name); - insert_single(vm,vm_id,*parsed,name); + insert_single(vm,*parsed,name); if ( $2 != '\0' ) { @@ -220,7 +177,7 @@ vm_variable:RSTRING VM_VAR_TO_UPPER(name); VM_VAR_TO_UPPER(vname); - insert_vector(vm,vm_id,*parsed,name,vname,"",""); + insert_vector(vm,*parsed,name,vname,"",""); if ( $5 != '\0' ) { @@ -241,7 +198,7 @@ vm_variable:RSTRING VM_VAR_TO_UPPER(vname); VM_VAR_TO_UPPER(vvar); - insert_vector(vm,vm_id,*parsed,name,vname,vvar,vval); + insert_vector(vm,*parsed,name,vname,vvar,vval); if ( $9 != '\0' ) { @@ -253,29 +210,12 @@ vm_variable:RSTRING free($5); free($7); } - | INTEGER VARIABLE EOA - { - string name("CONTEXT"); - string vname($2); - - VM_VAR_TO_UPPER(vname); - - insert_vector(0,$1,*parsed,name,vname,"",""); - - if ( $3 != '\0' ) - { - (*parsed) << $3; - } - - free($2); - } ; %% extern "C" void vm_var_error( YYLTYPE * llocp, VirtualMachine * vm, - int vm_id, ostringstream * parsed, char ** error_msg, const char * str) From ec6b21ef9dd9e26663ef9316e7db35efd4675b8d Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 5 Mar 2010 19:43:34 +0100 Subject: [PATCH 04/25] feature #189: Added VNC_BASE_PORT to the configuration file, and PORT generation --- share/etc/oned.conf | 5 +++++ src/nebula/NebulaTemplate.cc | 6 ++++++ src/vm/VirtualMachine.cc | 16 +++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 9fc39c6e41..8fd55313dc 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -15,6 +15,9 @@ # # PORT: Port where oned will listen for xmlrpc calls. # +# VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT + +# VMID +# # DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG #******************************************************************************* @@ -26,6 +29,8 @@ VM_POLLING_INTERVAL = 60 PORT=2633 +VNC_BASE_PORT = 5000 + DEBUG_LEVEL=3 #******************************************************************************* diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 5dbffaf065..fa3b39ac61 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -75,6 +75,12 @@ NebulaTemplate::NebulaTemplate(string& etc_location, string& var_location) attribute = new SingleAttribute("NETWORK_SIZE",value); conf_default.insert(make_pair(attribute->name(),attribute)); + + //NETWORK_SIZE + value = "5900"; + + attribute = new SingleAttribute("VNC_BASE_PORT",value); + conf_default.insert(make_pair(attribute->name(),attribute)); //DEBUG_LEVEL value = Log::WARNING; diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 062d9b15e0..be6c495475 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -468,10 +468,20 @@ void VirtualMachine::parse_graphics() if ( port.empty() ) { - ostringstream oss; + Nebula& nd = Nebula::instance(); - oss << ( 5900 + oid ); - graphics->replace("PORT", oss.str()); + ostringstream oss; + istringstream iss; + + int base_port; + string base_port_s; + + nd.get_configuration_attribute("VNC_BASE_PORT",base_port_s); + iss.str(base_port_s); + iss >> base_port; + + oss << ( base_port + oid ); + graphics->replace("PORT", oss.str()); } } From 3366abdb7f277386de55c108f3d6330227c0b856 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 6 Mar 2010 00:15:03 +0100 Subject: [PATCH 05/25] feature #189: Support to access NETWORK templates in VM CONTEXT (e.g. $NETWORK[DNS]) --- include/VirtualNetwork.h | 114 ++++++++++++++++++++------------------- src/vm/vm_var_syntax.cc | 98 ++++++++++++++++++++++++++++----- src/vm/vm_var_syntax.h | 2 +- src/vm/vm_var_syntax.y | 74 ++++++++++++++++++++++++- 4 files changed, 217 insertions(+), 71 deletions(-) diff --git a/include/VirtualNetwork.h b/include/VirtualNetwork.h index 7aae346946..d1301378ec 100644 --- a/include/VirtualNetwork.h +++ b/include/VirtualNetwork.h @@ -140,7 +140,64 @@ public: * @return a reference to the generated string */ string& to_xml(string& xml) const; - + + //------------------------------------------------------------------------ + // Template + // ------------------------------------------------------------------------ + + /** + * Gets the values of a template attribute + * @param name of the attribute + * @param values of the attribute + * @return the number of values + */ + int get_template_attribute( + string& name, + vector& values) const + { + return vn_template.get(name,values); + }; + + /** + * Gets the values of a template attribute + * @param name of the attribute + * @param values of the attribute + * @return the number of values + */ + int get_template_attribute( + const char *name, + vector& values) const + { + string str=name; + return vn_template.get(str,values); + }; + + /** + * Gets a string based VN attribute + * @param name of the attribute + * @param value of the attribute (a string), will be "" if not defined + */ + void get_template_attribute( + const char * name, + string& value) const + { + string str=name; + vn_template.get(str,value); + } + + /** + * Gets a string based VN attribute + * @param name of the attribute + * @param value of the attribute (an int), will be 0 if not defined + */ + void get_template_attribute( + const char * name, + int& value) const + { + string str=name; + vn_template.get(str,value); + } + private: // ------------------------------------------------------------------------- @@ -262,62 +319,7 @@ private: */ int vn_drop(SqliteDB * db); - // ------------------------------------------------------------------------ - // Template - // ------------------------------------------------------------------------ - /** - * Gets the values of a template attribute - * @param name of the attribute - * @param values of the attribute - * @return the number of values - */ - int get_template_attribute( - string& name, - vector& values) const - { - return vn_template.get(name,values); - }; - - /** - * Gets the values of a template attribute - * @param name of the attribute - * @param values of the attribute - * @return the number of values - */ - int get_template_attribute( - const char *name, - vector& values) const - { - string str=name; - return vn_template.get(str,values); - }; - - /** - * Gets a string based VN attribute - * @param name of the attribute - * @param value of the attribute (a string), will be "" if not defined - */ - void get_template_attribute( - const char * name, - string& value) const - { - string str=name; - vn_template.get(str,value); - } - - /** - * Gets a string based VN attribute - * @param name of the attribute - * @param value of the attribute (an int), will be 0 if not defined - */ - void get_template_attribute( - const char * name, - int& value) const - { - string str=name; - vn_template.get(str,value); - } /** * Updates the template of a VNW, adding a new attribute (replacing it if diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index fdbe89b0f6..ce4f89b20d 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -115,6 +115,65 @@ int vm_var_parse (VirtualMachine * vm, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void get_network_attribute(VirtualMachine * vm, + const string& attr_name, + const string& net_name, + const string& net_value, + string& attr_value) +{ + Nebula& nd = Nebula::instance(); + + VirtualNetworkPool * vnpool = nd.get_vnpool(); + VirtualNetwork * vn; + + string network = ""; + + attr_value = ""; + + if (net_name.empty()) + { + vector nics; + const VectorAttribute * nic; + + if (vm->get_template_attribute("NIC",nics) == 0) + { + return; + } + + nic = dynamic_cast(nics[0]); + + if ( nic == 0 ) + { + return; + } + + network = nic->vector_value("NETWORK"); + } + else if (net_name == "NAME") + { + network = net_value; + } + + if ( network.empty() ) + { + return; + } + + vn = vnpool->get(network,true); + + if ( vn == 0 ) + { + return; + } + + vn->get_template_attribute(attr_name.c_str(),attr_value); + + vn->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void insert_single(VirtualMachine * vm, ostringstream& parsed, const string& name) @@ -141,7 +200,20 @@ void insert_vector(VirtualMachine * vm, const VectorAttribute * vattr = 0; int num; - string value = ""; + + if ( name == "NETWORK") + { + string value; + + get_network_attribute(vm,vname,vvar,vval,value); + + if (!value.empty()) + { + parsed << value; + } + + return; + } if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 ) { @@ -180,7 +252,7 @@ void insert_vector(VirtualMachine * vm, /* Line 189 of yacc.c */ -#line 184 "vm_var_syntax.cc" +#line 256 "vm_var_syntax.cc" /* Enabling traces. */ #ifndef YYDEBUG @@ -226,7 +298,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 124 "vm_var_syntax.y" +#line 196 "vm_var_syntax.y" char * val_str; int val_int; @@ -235,7 +307,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 239 "vm_var_syntax.cc" +#line 311 "vm_var_syntax.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -260,7 +332,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 264 "vm_var_syntax.cc" +#line 336 "vm_var_syntax.cc" #ifdef short # undef short @@ -544,9 +616,9 @@ static const yytype_int8 yyrhs[] = }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = +static const yytype_uint16 yyrline[] = { - 0, 148, 148, 149, 152, 157, 172, 190 + 0, 220, 220, 221, 224, 229, 244, 262 }; #endif @@ -1503,7 +1575,7 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 153 "vm_var_syntax.y" +#line 225 "vm_var_syntax.y" { (*parsed) << (yyvsp[(1) - (1)].val_str); free((yyvsp[(1) - (1)].val_str)); @@ -1513,7 +1585,7 @@ yyreduce: case 5: /* Line 1455 of yacc.c */ -#line 158 "vm_var_syntax.y" +#line 230 "vm_var_syntax.y" { string name((yyvsp[(1) - (2)].val_str)); @@ -1533,7 +1605,7 @@ yyreduce: case 6: /* Line 1455 of yacc.c */ -#line 173 "vm_var_syntax.y" +#line 245 "vm_var_syntax.y" { string name((yyvsp[(1) - (5)].val_str)); string vname((yyvsp[(3) - (5)].val_str)); @@ -1556,7 +1628,7 @@ yyreduce: case 7: /* Line 1455 of yacc.c */ -#line 191 "vm_var_syntax.y" +#line 263 "vm_var_syntax.y" { string name((yyvsp[(1) - (9)].val_str)); string vname((yyvsp[(3) - (9)].val_str)); @@ -1584,7 +1656,7 @@ yyreduce: /* Line 1455 of yacc.c */ -#line 1588 "vm_var_syntax.cc" +#line 1660 "vm_var_syntax.cc" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1803,7 +1875,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 214 "vm_var_syntax.y" +#line 286 "vm_var_syntax.y" extern "C" void vm_var_error( diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index dc91f22220..bcd292ff26 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -58,7 +58,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 124 "vm_var_syntax.y" +#line 196 "vm_var_syntax.y" char * val_str; int val_int; diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index deb1dc9f96..3031ef707f 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -53,6 +53,65 @@ int vm_var_parse (VirtualMachine * vm, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +void get_network_attribute(VirtualMachine * vm, + const string& attr_name, + const string& net_name, + const string& net_value, + string& attr_value) +{ + Nebula& nd = Nebula::instance(); + + VirtualNetworkPool * vnpool = nd.get_vnpool(); + VirtualNetwork * vn; + + string network = ""; + + attr_value = ""; + + if (net_name.empty()) + { + vector nics; + const VectorAttribute * nic; + + if (vm->get_template_attribute("NIC",nics) == 0) + { + return; + } + + nic = dynamic_cast(nics[0]); + + if ( nic == 0 ) + { + return; + } + + network = nic->vector_value("NETWORK"); + } + else if (net_name == "NAME") + { + network = net_value; + } + + if ( network.empty() ) + { + return; + } + + vn = vnpool->get(network,true); + + if ( vn == 0 ) + { + return; + } + + vn->get_template_attribute(attr_name.c_str(),attr_value); + + vn->unlock(); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + void insert_single(VirtualMachine * vm, ostringstream& parsed, const string& name) @@ -79,7 +138,20 @@ void insert_vector(VirtualMachine * vm, const VectorAttribute * vattr = 0; int num; - string value = ""; + + if ( name == "NETWORK") + { + string value; + + get_network_attribute(vm,vname,vvar,vval,value); + + if (!value.empty()) + { + parsed << value; + } + + return; + } if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 ) { From 73d8a739fa3e96ce62e43b9fc1619c143bad258a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Mon, 10 May 2010 17:11:04 +0200 Subject: [PATCH 06/25] feature-#239: Econe server now responds to get. Authorization improvements --- src/cloud/ec2/lib/EC2QueryServer.rb | 10 +++++++--- src/cloud/ec2/lib/econe-server.rb | 14 +++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 4609d7a26a..6ff51cfe50 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -69,6 +69,8 @@ class EC2QueryServer < CloudServer @server_host=@config[:server] end + @server_port=@config[:port] + print_configuration end @@ -79,7 +81,7 @@ class EC2QueryServer < CloudServer # EC2 protocol authentication function # params:: of the request # [return] true if authenticated - def authenticate?(params) + def authenticate?(params,env) user = get_user(params['AWSAccessKeyId']) return false if !user @@ -88,9 +90,9 @@ class EC2QueryServer < CloudServer signature = AWS.encode( user[:password], - AWS.canonical_string(signature_params, @server_host), + AWS.canonical_string(signature_params, @server_host + ":" + @server_port, env['REQUEST_METHOD']), false) - + return params['Signature']==signature end @@ -166,6 +168,7 @@ class EC2QueryServer < CloudServer #Start the VM. vm = VirtualMachine.new(VirtualMachine.build_xml, one_client) +puts template_text rc = vm.allocate(template_text) return rc, 401 if OpenNebula::is_error?(rc) @@ -206,6 +209,7 @@ class EC2QueryServer < CloudServer one_client = one_client_user(user) vmid=params['InstanceId.1'] + tmp, vmid=vmid.split('-') if vmid[0]==?i erb_vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client) rc = erb_vm.info diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 3c38ece1ec..5ebc6def22 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -59,12 +59,20 @@ set :port, $econe_server.config[:port] ############################################################################## before do - if !$econe_server.authenticate?(params) + if !$econe_server.authenticate?(params,env) halt 401, 'Invalid credentials' end end post '/' do + do_http_request(params) +end + +get '/' do + do_http_request(params) +end + +def do_http_request(params) case params['Action'] when 'UploadImage' result,rc = $econe_server.upload_image(params) @@ -79,10 +87,10 @@ post '/' do when 'TerminateInstances' result,rc = $econe_server.terminate_instances(params) end - + if OpenNebula::is_error?(result) halt rc, result.message end - result + result end From 21b29e5c0e6a6024a68f9f368a1868467edfcf9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Mon, 10 May 2010 17:14:18 +0200 Subject: [PATCH 07/25] feature-#239: Comply with i-* notation for running VMs identifiers --- src/cloud/ec2/lib/views/describe_instances.erb | 2 +- src/cloud/ec2/lib/views/run_instances.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cloud/ec2/lib/views/describe_instances.erb b/src/cloud/ec2/lib/views/describe_instances.erb index 28740fcba0..6d0a0dd228 100644 --- a/src/cloud/ec2/lib/views/describe_instances.erb +++ b/src/cloud/ec2/lib/views/describe_instances.erb @@ -12,7 +12,7 @@ <% erb_vmpool.each do |vm| %> <% vm.info %> - <%= vm.id %> + i-<%= vm.id %> <%= vm['TEMPLATE/IMAGE_ID'] %> <%= render_state(vm) %> diff --git a/src/cloud/ec2/lib/views/run_instances.erb b/src/cloud/ec2/lib/views/run_instances.erb index 7481d4f978..b431406d05 100644 --- a/src/cloud/ec2/lib/views/run_instances.erb +++ b/src/cloud/ec2/lib/views/run_instances.erb @@ -8,7 +8,7 @@ - <%= erb_vm_info[:vm_id] %> + i-<%= erb_vm_info[:vm_id] %> <%= erb_vm_info[:img_id] %> 0 From d29c26b1caa5f3001381cd71c1599bee9d8bdb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Thu, 13 May 2010 15:23:26 +0200 Subject: [PATCH 08/25] feature-#239: Authenticating version 1 and 2 of the AWS signature --- src/cloud/ec2/lib/EC2QueryServer.rb | 64 ++++++++++++++++--- src/cloud/ec2/lib/econe-server.rb | 4 ++ src/cloud/ec2/lib/views/describe_images.erb | 7 +- .../ec2/lib/views/describe_instances.erb | 12 +++- .../ec2/lib/views/terminate_instances.erb | 2 +- 5 files changed, 75 insertions(+), 14 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 6ff51cfe50..0a96ced77b 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -20,6 +20,8 @@ require 'erb' require 'time' require 'AWS' require 'CloudServer' +require 'base64' + ############################################################################### # The EC2Query Server implements a EC2 compatible server based on the # OpenNebula Engine @@ -84,16 +86,57 @@ class EC2QueryServer < CloudServer def authenticate?(params,env) user = get_user(params['AWSAccessKeyId']) return false if !user - + + signature = case params['SignatureVersion'] + when "1" then signature_version_1(params.clone, user[:password]) + when "2" then signature_version_2(params, + user[:password], + env, + false) + end + + return params['Signature']==signature + end + + # Calculates signature version 1 + def signature_version_1(params, secret_key, digest='sha1') + params.delete('Signature') + req_desc = params.sort {|x,y| x[0].downcase <=> y[0].downcase}.to_s + + digest_generator = OpenSSL::Digest::Digest.new(digest) + digest = OpenSSL::HMAC.digest(digest_generator, + secret_key, + req_desc) + b64sig = Base64.b64encode(digest) + return b64sig.strip + end + + # Calculates signature version 2 + def signature_version_2(params, secret_key, env, urlencode=true) signature_params = params.reject { |key,value| key=='Signature' or key=='file' } - signature = AWS.encode( - user[:password], - AWS.canonical_string(signature_params, @server_host + ":" + @server_port, env['REQUEST_METHOD']), - false) + canonical_str = AWS.canonical_string(signature_params, + @server_host + ":" + @server_port, + env['REQUEST_METHOD']) - return params['Signature']==signature + # Use the correct signature strength + sha_strength = case params['SignatureMethod'] + when "HmacSHA1" then 'sha1' + when "HmacSHA256" then 'sha256' + else 'sha1' + end + + digest = OpenSSL::Digest::Digest.new(sha_strength) + b64hmac = + Base64.encode64( + OpenSSL::HMAC.digest(digest, secret_key, canonical_str)).gsub("\n","") + + if urlencode + return CGI::escape(b64hmac) + else + return b64hmac + end end ########################################################################### @@ -146,7 +189,8 @@ class EC2QueryServer < CloudServer return OpenNebula::Error.new('Bad instance type'),400 if !instance_type # Get the image - image = get_image(params['ImageId']) + tmp, img=params['ImageId'].split('-') + image = get_image(img.to_i) return OpenNebula::Error.new('Bad image id'),400 if !image @@ -168,7 +212,7 @@ class EC2QueryServer < CloudServer #Start the VM. vm = VirtualMachine.new(VirtualMachine.build_xml, one_client) -puts template_text + rc = vm.allocate(template_text) return rc, 401 if OpenNebula::is_error?(rc) @@ -207,8 +251,10 @@ puts template_text # Get the user user = get_user(params['AWSAccessKeyId']) one_client = one_client_user(user) - + vmid=params['InstanceId.1'] + vmid=params['InstanceId.01'] if !vmid + tmp, vmid=vmid.split('-') if vmid[0]==?i erb_vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client) diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 5ebc6def22..c8374e6ff6 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -88,9 +88,13 @@ def do_http_request(params) result,rc = $econe_server.terminate_instances(params) end + puts result + if OpenNebula::is_error?(result) halt rc, result.message end + headers['Content-Type'] = 'application/xml' + result end diff --git a/src/cloud/ec2/lib/views/describe_images.erb b/src/cloud/ec2/lib/views/describe_images.erb index c7f2972a56..f042580a38 100644 --- a/src/cloud/ec2/lib/views/describe_images.erb +++ b/src/cloud/ec2/lib/views/describe_images.erb @@ -1,9 +1,10 @@ - + + <% for image in erb_images %> - <%= image.id %> - <%= image.path %> + ami-<%= sprintf('%08i', image.id) %> + <%= image.path.gsub(/^\//,'') %> available <%= erb_user[:name] %> false diff --git a/src/cloud/ec2/lib/views/describe_instances.erb b/src/cloud/ec2/lib/views/describe_instances.erb index 6d0a0dd228..73c418dc05 100644 --- a/src/cloud/ec2/lib/views/describe_instances.erb +++ b/src/cloud/ec2/lib/views/describe_instances.erb @@ -1,4 +1,6 @@ - + + + 4ac62eaf-e266-4058-a970-2c01568cd417 default @@ -21,11 +23,19 @@ <%= vm["TEMPLATE/NIC/IP"] %> default 0 + <%= vm['TEMPLATE/INSTANCE_TYPE'] %> <%= render_launch_time(vm) %> default + + eki-EA801065 + eri-1FEE1144 + + false + + <% end %> diff --git a/src/cloud/ec2/lib/views/terminate_instances.erb b/src/cloud/ec2/lib/views/terminate_instances.erb index cdfc177699..d79c077a73 100644 --- a/src/cloud/ec2/lib/views/terminate_instances.erb +++ b/src/cloud/ec2/lib/views/terminate_instances.erb @@ -1,7 +1,7 @@ - <%= erb_vm.id %> + i-<%= erb_vm.id %> 32 shutting-down From b6e37fbcb21be1a737dccff14c76a7830aedfba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Thu, 13 May 2010 17:11:13 +0200 Subject: [PATCH 09/25] feature-#239: amazon-ec2 gem used by econe tools use just server for authentication (not the port) --- src/cloud/ec2/lib/EC2QueryServer.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 0a96ced77b..d93f537d59 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -116,8 +116,12 @@ class EC2QueryServer < CloudServer signature_params = params.reject { |key,value| key=='Signature' or key=='file' } + + server_str = @server_host + server_str = server_str + ":" + @server_port if params["Version"] != "2008-12-01" + canonical_str = AWS.canonical_string(signature_params, - @server_host + ":" + @server_port, + server_str, env['REQUEST_METHOD']) # Use the correct signature strength From d2153472ffc1163ce0b082d98cb2930d59bab26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Thu, 13 May 2010 18:33:02 +0200 Subject: [PATCH 10/25] feature-#239: Take into account version in the XML response. Removed debug puts --- src/cloud/ec2/lib/EC2QueryServer.rb | 11 +++++++++-- src/cloud/ec2/lib/econe-server.rb | 2 -- src/cloud/ec2/lib/views/describe_images.erb | 2 +- src/cloud/ec2/lib/views/describe_instances.erb | 2 +- src/cloud/ec2/lib/views/register_image.erb | 2 +- src/cloud/ec2/lib/views/run_instances.erb | 2 +- src/cloud/ec2/lib/views/terminate_instances.erb | 2 +- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index d93f537d59..75fb2af0cf 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -174,8 +174,9 @@ class EC2QueryServer < CloudServer end def describe_images(params) - erb_user = get_user(params['AWSAccessKeyId']) - erb_images = Image.filter(:owner => erb_user[:id]) + erb_user = get_user(params['AWSAccessKeyId']) + erb_images = Image.filter(:owner => erb_user[:id]) + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/describe_images.erb")) return response.result(binding), 200 @@ -225,6 +226,8 @@ class EC2QueryServer < CloudServer erb_vm_info[:vm_id]=vm.id erb_vm_info[:vm]=vm + + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/run_instances.erb")) return response.result(binding), 200 @@ -246,6 +249,8 @@ class EC2QueryServer < CloudServer erb_vmpool = VirtualMachinePool.new(one_client, user_flag) erb_vmpool.info + + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/describe_instances.erb")) return response.result(binding), 200 @@ -273,6 +278,8 @@ class EC2QueryServer < CloudServer end return rc, 401 if OpenNebula::is_error?(rc) + + erb_version = params['Version'] response =ERB.new(File.read(@config[:views]+"/terminate_instances.erb")) return response.result(binding), 200 diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index c8374e6ff6..4c3ab8b765 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -88,8 +88,6 @@ def do_http_request(params) result,rc = $econe_server.terminate_instances(params) end - puts result - if OpenNebula::is_error?(result) halt rc, result.message end diff --git a/src/cloud/ec2/lib/views/describe_images.erb b/src/cloud/ec2/lib/views/describe_images.erb index f042580a38..6d5156ba5a 100644 --- a/src/cloud/ec2/lib/views/describe_images.erb +++ b/src/cloud/ec2/lib/views/describe_images.erb @@ -1,5 +1,5 @@ - + <% for image in erb_images %> diff --git a/src/cloud/ec2/lib/views/describe_instances.erb b/src/cloud/ec2/lib/views/describe_instances.erb index 73c418dc05..db1bc36c79 100644 --- a/src/cloud/ec2/lib/views/describe_instances.erb +++ b/src/cloud/ec2/lib/views/describe_instances.erb @@ -1,5 +1,5 @@ - + 4ac62eaf-e266-4058-a970-2c01568cd417 diff --git a/src/cloud/ec2/lib/views/register_image.erb b/src/cloud/ec2/lib/views/register_image.erb index 753487bc2d..6f2fbf608d 100644 --- a/src/cloud/ec2/lib/views/register_image.erb +++ b/src/cloud/ec2/lib/views/register_image.erb @@ -1,3 +1,3 @@ - + <%= erb_img_id %> diff --git a/src/cloud/ec2/lib/views/run_instances.erb b/src/cloud/ec2/lib/views/run_instances.erb index b431406d05..a33481372c 100644 --- a/src/cloud/ec2/lib/views/run_instances.erb +++ b/src/cloud/ec2/lib/views/run_instances.erb @@ -1,4 +1,4 @@ - + r-47a5402e <%= erb_user_name %> diff --git a/src/cloud/ec2/lib/views/terminate_instances.erb b/src/cloud/ec2/lib/views/terminate_instances.erb index d79c077a73..954460988c 100644 --- a/src/cloud/ec2/lib/views/terminate_instances.erb +++ b/src/cloud/ec2/lib/views/terminate_instances.erb @@ -1,4 +1,4 @@ - + i-<%= erb_vm.id %> From 81410256d0febfbf29ab85251a24752e92ea338c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantino=20V=C3=A1zquez=20Blanco?= Date: Tue, 8 Jun 2010 11:22:15 +0200 Subject: [PATCH 11/25] Bug #246: Check OpenNebula error and if leases exists --- src/cloud/occi/lib/OCCIServer.rb | 5 +++++ src/vnm/VirtualNetwork.cc | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index b45d4b4661..4e46eef40c 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -235,6 +235,11 @@ class OCCIServer < CloudServer network_info['NETWORK'], @config[:bridge]) rc = network.allocate(vntemplate) + + if OpenNebula::is_error?(rc) + return rc, 404 + end + network.info network_xml = network.to_occi return network_xml, 201 diff --git a/src/vnm/VirtualNetwork.cc b/src/vnm/VirtualNetwork.cc index 5c38882290..78feb6249d 100644 --- a/src/vnm/VirtualNetwork.cc +++ b/src/vnm/VirtualNetwork.cc @@ -477,7 +477,10 @@ int VirtualNetwork::vn_drop(SqliteDB * db) vn_template.drop(db); - leases->drop(db); + if (leases) + { + leases->drop(db); + } oss << "DELETE FROM " << table << " WHERE OID=" << oid; From 88846f1c028ac5f5c022a455d2d1b4502fb6c637 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 7 Jun 2010 10:39:41 +0200 Subject: [PATCH 12/25] Fixed whitespaces --- src/cloud/ec2/lib/EC2QueryServer.rb | 44 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 75fb2af0cf..6923120593 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -116,29 +116,31 @@ class EC2QueryServer < CloudServer signature_params = params.reject { |key,value| key=='Signature' or key=='file' } - - server_str = @server_host - server_str = server_str + ":" + @server_port if params["Version"] != "2008-12-01" + server_str = @server_host + server_str = server_str + ":" + @server_port unless %w{2008-12-01 2009-11-30}.include? params["Version"] + + pp params["Version"] canonical_str = AWS.canonical_string(signature_params, server_str, env['REQUEST_METHOD']) + # Use the correct signature strength - sha_strength = case params['SignatureMethod'] - when "HmacSHA1" then 'sha1' - when "HmacSHA256" then 'sha256' - else 'sha1' - end + sha_strength = case params['SignatureMethod'] + when "HmacSHA1" then 'sha1' + when "HmacSHA256" then 'sha256' + else 'sha1' + end - digest = OpenSSL::Digest::Digest.new(sha_strength) - b64hmac = - Base64.encode64( - OpenSSL::HMAC.digest(digest, secret_key, canonical_str)).gsub("\n","") + digest = OpenSSL::Digest::Digest.new(sha_strength) + b64hmac = + Base64.encode64( + OpenSSL::HMAC.digest(digest, secret_key, canonical_str)).gsub("\n","") - if urlencode + if urlencode return CGI::escape(b64hmac) - else + else return b64hmac end end @@ -176,9 +178,10 @@ class EC2QueryServer < CloudServer def describe_images(params) erb_user = get_user(params['AWSAccessKeyId']) erb_images = Image.filter(:owner => erb_user[:id]) - erb_version = params['Version'] + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/describe_images.erb")) + return response.result(binding), 200 end @@ -194,7 +197,7 @@ class EC2QueryServer < CloudServer return OpenNebula::Error.new('Bad instance type'),400 if !instance_type # Get the image - tmp, img=params['ImageId'].split('-') + tmp, img=params['ImageId'].split('-') image = get_image(img.to_i) return OpenNebula::Error.new('Bad image id'),400 if !image @@ -227,7 +230,7 @@ class EC2QueryServer < CloudServer erb_vm_info[:vm_id]=vm.id erb_vm_info[:vm]=vm - erb_version = params['Version'] + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/run_instances.erb")) return response.result(binding), 200 @@ -250,9 +253,10 @@ class EC2QueryServer < CloudServer erb_vmpool = VirtualMachinePool.new(one_client, user_flag) erb_vmpool.info - erb_version = params['Version'] + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/describe_instances.erb")) + return response.result(binding), 200 end @@ -264,7 +268,7 @@ class EC2QueryServer < CloudServer vmid=params['InstanceId.1'] vmid=params['InstanceId.01'] if !vmid - tmp, vmid=vmid.split('-') if vmid[0]==?i + tmp, vmid=vmid.split('-') if vmid[0]==?i erb_vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client) rc = erb_vm.info @@ -279,7 +283,7 @@ class EC2QueryServer < CloudServer return rc, 401 if OpenNebula::is_error?(rc) - erb_version = params['Version'] + erb_version = params['Version'] response =ERB.new(File.read(@config[:views]+"/terminate_instances.erb")) return response.result(binding), 200 From 7f13bf4beeb566d2bcd30b8ace8039c28a2f1c9f Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 7 Jun 2010 10:42:07 +0200 Subject: [PATCH 13/25] Fixed help information --- src/cloud/ec2/bin/econe-describe-images | 2 +- src/cloud/ec2/bin/econe-terminate-instances | 2 +- src/cloud/ec2/bin/econe-upload | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cloud/ec2/bin/econe-describe-images b/src/cloud/ec2/bin/econe-describe-images index 80e2cf6a01..e1506e1ad9 100755 --- a/src/cloud/ec2/bin/econe-describe-images +++ b/src/cloud/ec2/bin/econe-describe-images @@ -16,7 +16,7 @@ # --access-key , -K : # The username of the user # -# --secret-key , -K : +# --secret-key , -S : # The password of the user # # --url , -U : diff --git a/src/cloud/ec2/bin/econe-terminate-instances b/src/cloud/ec2/bin/econe-terminate-instances index bf1e42c34d..8fee23000b 100755 --- a/src/cloud/ec2/bin/econe-terminate-instances +++ b/src/cloud/ec2/bin/econe-terminate-instances @@ -15,7 +15,7 @@ # --access-key , -K : # The username of the user # -# --secret-key , -K : +# --secret-key , -S : # The password of the user # # --url , -U : diff --git a/src/cloud/ec2/bin/econe-upload b/src/cloud/ec2/bin/econe-upload index 6a4762b19d..e88b0bce7d 100755 --- a/src/cloud/ec2/bin/econe-upload +++ b/src/cloud/ec2/bin/econe-upload @@ -16,7 +16,7 @@ # --access-key , -K : # The username of the user # -# --secret-key , -K : +# --secret-key , -S : # The password of the user # # --url , -U : From 23e40d1b19537aa5cdfae49fec3d1bb6c6395c06 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 7 Jun 2010 10:43:38 +0200 Subject: [PATCH 14/25] Fixed #bug 241 --- src/cloud/ec2/lib/EC2QueryServer.rb | 14 +++++++------- src/cloud/ec2/lib/econe-server.rb | 29 +++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 6923120593..6b38447b1b 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -164,9 +164,9 @@ class EC2QueryServer < CloudServer image = get_image(params['ImageLocation']) if !image - return OpenNebula::Error.new('Image not found'), 404 + return OpenNebula::Error.new('InvalidAMIID.NotFound'), 400 elsif user[:id] != image[:owner] - return OpenNebula::Error.new('Not permited to use image'), 401 + return OpenNebula::Error.new('AuthFailure'), 400 end erb_img_id=image.id @@ -194,13 +194,13 @@ class EC2QueryServer < CloudServer instance_type_name = params['InstanceType'] instance_type = @instance_types[instance_type_name] - return OpenNebula::Error.new('Bad instance type'),400 if !instance_type + return OpenNebula::Error.new('Unsupported'),400 if !instance_type # Get the image tmp, img=params['ImageId'].split('-') image = get_image(img.to_i) - return OpenNebula::Error.new('Bad image id'),400 if !image + return OpenNebula::Error.new('InvalidAMIID.NotFound'),400 if !image # Get the user user = get_user(params['AWSAccessKeyId']) @@ -223,7 +223,7 @@ class EC2QueryServer < CloudServer rc = vm.allocate(template_text) - return rc, 401 if OpenNebula::is_error?(rc) + return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc) vm.info @@ -273,7 +273,7 @@ class EC2QueryServer < CloudServer erb_vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client) rc = erb_vm.info - return rc, 401 if OpenNebula::is_error?(rc) + return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc) if erb_vm.status == 'runn' rc = erb_vm.shutdown @@ -281,7 +281,7 @@ class EC2QueryServer < CloudServer rc = erb_vm.finalize end - return rc, 401 if OpenNebula::is_error?(rc) + return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc) erb_version = params['Version'] diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 4c3ab8b765..58f8f668a5 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -60,10 +60,35 @@ set :port, $econe_server.config[:port] before do if !$econe_server.authenticate?(params,env) - halt 401, 'Invalid credentials' + error 400, error_xml("AuthFailure", 0) end end +helpers do + def error_xml(code,id) + message = '' + + case code + when 'AuthFailure' + message = 'User not authorized' + when 'InvalidAMIID.NotFound' + message = 'Specified AMI ID does not exist' + when 'Unsupported' + message = 'The instance type or feature is not supported in your requested Availability Zone.' + end + + xml = ""+ + code + + "" + + message + + "" + + id.to_s + + "" + + return xml + end +end + post '/' do do_http_request(params) end @@ -89,7 +114,7 @@ def do_http_request(params) end if OpenNebula::is_error?(result) - halt rc, result.message + error rc, error_xml(result.message, 0) end headers['Content-Type'] = 'application/xml' From 57e36f11b001d4e0931c09ed37b66b8b3c029bdb Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Mon, 7 Jun 2010 12:29:04 +0200 Subject: [PATCH 15/25] feature #239: Removed printed information --- src/cloud/ec2/lib/EC2QueryServer.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 6b38447b1b..623fa17aed 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -120,7 +120,6 @@ class EC2QueryServer < CloudServer server_str = @server_host server_str = server_str + ":" + @server_port unless %w{2008-12-01 2009-11-30}.include? params["Version"] - pp params["Version"] canonical_str = AWS.canonical_string(signature_params, server_str, env['REQUEST_METHOD']) From 5a26d3fcf888e163ddccbdcb83bc031cf3e9221c Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Sun, 13 Jun 2010 12:57:35 +0200 Subject: [PATCH 16/25] feature #239: Fixed whitespaces. erb_version forgotten --- src/cloud/ec2/lib/EC2QueryServer.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 623fa17aed..234610548e 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -71,7 +71,7 @@ class EC2QueryServer < CloudServer @server_host=@config[:server] end - @server_port=@config[:port] + @server_port=@config[:port] print_configuration end @@ -87,13 +87,13 @@ class EC2QueryServer < CloudServer user = get_user(params['AWSAccessKeyId']) return false if !user - signature = case params['SignatureVersion'] - when "1" then signature_version_1(params.clone, user[:password]) - when "2" then signature_version_2(params, - user[:password], - env, - false) - end + signature = case params['SignatureVersion'] + when "1" then signature_version_1(params.clone, user[:password]) + when "2" then signature_version_2(params, + user[:password], + env, + false) + end return params['Signature']==signature end @@ -153,6 +153,7 @@ class EC2QueryServer < CloudServer image = add_image(user[:id],params["file"][:tempfile]) erb_img_id = image.id + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/register_image.erb")) return response.result(binding), 200 @@ -169,6 +170,7 @@ class EC2QueryServer < CloudServer end erb_img_id=image.id + erb_version = params['Version'] response = ERB.new(File.read(@config[:views]+"/register_image.erb")) return response.result(binding), 200 From 1e5437bcb675d29cd63a66ae40edaec4c5eeda93 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Sun, 13 Jun 2010 13:00:49 +0200 Subject: [PATCH 17/25] feature #239: Added -d option for user_data --- src/cloud/ec2/bin/econe-run-instances | 6 +++++- src/cloud/ec2/lib/EC2QueryClient.rb | 12 +++++++----- src/cloud/ec2/lib/EC2QueryServer.rb | 3 +++ src/cloud/ec2/lib/econe-server.rb | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/cloud/ec2/bin/econe-run-instances b/src/cloud/ec2/bin/econe-run-instances index e2d33ecf2c..5976650a6f 100755 --- a/src/cloud/ec2/bin/econe-run-instances +++ b/src/cloud/ec2/bin/econe-run-instances @@ -68,6 +68,7 @@ opts = GetoptLong.new( ['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT], ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT], ['--type', '-t',GetoptLong::REQUIRED_ARGUMENT], + ['--user-data', '-d',GetoptLong::REQUIRED_ARGUMENT], ['--headers', '-H',GetoptLong::NO_ARGUMENT] ) @@ -77,6 +78,7 @@ access = nil secret = nil auth = nil type = nil +user_data = nil begin opts.each do |opt, arg| @@ -93,6 +95,8 @@ begin type = arg when '--headers' headers = true + when '--user-data' + user_data = arg end end rescue Exception => e @@ -119,7 +123,7 @@ rescue Exception => e exit -1 end -rc = ec2_client.run_instances(image_id,type) +rc = ec2_client.run_instances(image_id,type, user_data) if CloudClient::is_error?(rc) puts "#{cmd_name}: #{rc.message}" diff --git a/src/cloud/ec2/lib/EC2QueryClient.rb b/src/cloud/ec2/lib/EC2QueryClient.rb index 0f0e56ae92..aa08866075 100644 --- a/src/cloud/ec2/lib/EC2QueryClient.rb +++ b/src/cloud/ec2/lib/EC2QueryClient.rb @@ -97,13 +97,15 @@ module EC2QueryClient # :image_id # :instance_type ###################################################################### - def run_instances(ami_id, type) + def run_instances(ami_id, type, user_data=nil) begin response = @ec2_connection.run_instances( - :image_id => ami_id, - :min_count => 1, - :max_count => 1, - :instance_type => type + :image_id => ami_id, + :min_count => 1, + :max_count => 1, + :instance_type => type, + :user_data => user_data, + :base64_encoded => true ) rescue Exception => e error = CloudClient::Error.new(e.message) diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 234610548e..c07e766a0b 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -211,11 +211,14 @@ class EC2QueryServer < CloudServer # Build the VM erb_vm_info=Hash.new + erb_vm_info[:img_path] = image.path erb_vm_info[:img_id] = params['ImageId'] erb_vm_info[:instance_type] = instance_type_name erb_vm_info[:template] = @config[:template_location] + "/#{instance_type['TEMPLATE']}" + erb_vm_info[:user_data] = params['UserData'] + template = ERB.new(File.read(erb_vm_info[:template])) template_text = template.result(binding) diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index 58f8f668a5..9fbc06f46e 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -75,6 +75,8 @@ helpers do message = 'Specified AMI ID does not exist' when 'Unsupported' message = 'The instance type or feature is not supported in your requested Availability Zone.' + else + message = code end xml = ""+ From 82ac36e3d516c5b0b5caa2c2ba0b3f1419772a59 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 16 Jun 2010 18:17:02 +0200 Subject: [PATCH 18/25] feature #239: Changes in m1.small erb example --- src/cloud/ec2/etc/templates/m1.small.erb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/cloud/ec2/etc/templates/m1.small.erb b/src/cloud/ec2/etc/templates/m1.small.erb index aadc207263..f8c099ee5d 100644 --- a/src/cloud/ec2/etc/templates/m1.small.erb +++ b/src/cloud/ec2/etc/templates/m1.small.erb @@ -1,23 +1,29 @@ NAME = eco-vm +#Adjust Capacity for this instance type CPU = 0.2 MEMORY = 256 -OS = [ kernel = /vmlinuz, - initrd = /initrd.img, - root = sda1, - kernel_cmd = "ro xencons=tty console=tty1"] +#Put here specific OS configurations for the cloud hypervisors +#OS = [ kernel = /vmlinuz, +# initrd = /initrd.img, +# root = sda1, +# kernel_cmd = "ro xencons=tty console=tty1"] DISK = [ source = <%= erb_vm_info[:img_path] %>, clone = no, target = sda1, readonly = no] - NIC=[NETWORK="Public EC2"] - IMAGE_ID = <%= erb_vm_info[:img_id] %> INSTANCE_TYPE = <%= erb_vm_info[:instance_type ]%> - + +<% if erb_vm_info[:user_data] %> +CONTEXT = [ + EC2_USER_DATA="<%= erb_vm_info[:user_data] %>", + TARGET="hdc" + ] +<% end %> From 67d8862cf9d7e14bd3570948db6fe51ba8f9a79c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 14 Jun 2010 17:55:36 +0200 Subject: [PATCH 19/25] feature #192: Dump tests fixed for new SQL schema. --- src/vm/test/VirtualMachinePoolTest.cc | 51 ++++++--------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/src/vm/test/VirtualMachinePoolTest.cc b/src/vm/test/VirtualMachinePoolTest.cc index 67c8396214..1c9913f8c0 100644 --- a/src/vm/test/VirtualMachinePoolTest.cc +++ b/src/vm/test/VirtualMachinePoolTest.cc @@ -69,42 +69,13 @@ const string xmls[] = // This xml dump result has the STIMEs modified to 0000000000 const string xml_dump = - "01A userVM one" - "01000000000000000012B userSecond VM0200000000000" - "00000"; + "01A userVM one010000000000000000-112B userSecond VM020000000000000000-1"; const string xml_dump_where = - "01A userVM one" - "010000000000000000"; + "01A userVM one010000000000000000-1"; const string xml_history_dump = - "00one_user_test" - "VM one01" - "000000000000" - "000" - "010" - "one_user_testSecond VM0" - "200000000000" - "000" - "000" - "A_hostname000" - "0000" - "0002" - "0one_user_testVM one" - "020" - "000000000000" - "0001" - "C_hostname200" - "0000" - "000" - ""; + "00one_user_testVM one010000000000000000-110one_user_testSecond VM02000000000000000000A_hostname000000000020one_user_testVM one02000000000000000011C_hostname2000000000"; const string replacement = "0000000000"; @@ -271,11 +242,11 @@ public: rc = vmp->dump(oss, ""); CPPUNIT_ASSERT(rc == 0); -cout << endl << oss.str() << endl; + string result = oss.str(); result.replace(152, 10, replacement); - result.replace(426, 10, replacement); - + result.replace(449, 10, replacement); + CPPUNIT_ASSERT( result == xml_dump ); } @@ -335,7 +306,7 @@ cout << endl << oss.str() << endl; // Add a history item vm->add_history(0, hostnames[0], vm_dirs[0], vmm_mads[0], tm_mads[0]); - rc = vmp->update(vm); + rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 ); rc = vmp->update_history(vm); @@ -353,7 +324,7 @@ cout << endl << oss.str() << endl; // Add a history item vm->add_history(1, hostnames[1], vm_dirs[1], vmm_mads[1], tm_mads[1]); - rc = vmp->update(vm); + rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 ); rc = vmp->update_history(vm); @@ -362,7 +333,7 @@ cout << endl << oss.str() << endl; // Add another history item vm->add_history(2, hostnames[2], vm_dirs[2], vmm_mads[2], tm_mads[2]); - rc = vmp->update(vm); + rc = vmp->update(vm); CPPUNIT_ASSERT( rc == 0 ); rc = vmp->update_history(vm); @@ -394,8 +365,8 @@ cout << endl << oss.str() << endl; string result = oss.str(); result.replace(159, 10, replacement); - result.replace(440, 10, replacement); - result.replace(950, 10, replacement); + result.replace(463, 10, replacement); + result.replace(995, 10, replacement); CPPUNIT_ASSERT( result == xml_history_dump ); } From 9311f27b412905f90fe98c5eac423810197e3799 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 24 Jun 2010 16:16:26 +0200 Subject: [PATCH 20/25] feature #189 Added info to CONTEXT and REQUIREMENTS template schema --- share/examples/vm.schema | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/share/examples/vm.schema b/share/examples/vm.schema index 94f85630b0..608c07ce03 100644 --- a/share/examples/vm.schema +++ b/share/examples/vm.schema @@ -88,11 +88,11 @@ RAW = [ # Optional, KVM, XEN #--------------------------------------- # Context for the VM -# values can be: +# values can use: # $ # $[] # $[, =] -# $. +# $NETWORK[, NAME=] #--------------------------------------- CONTEXT = [ # Optional, KVM, XEN @@ -102,7 +102,11 @@ CONTEXT = [ # Optional, KVM, XEN target= "device to attach the context device" ] #--------------------------------------- -# Scheduler +# Scheduler +# Requirements expressions can use: +# $ +# $[] +# $[, =] #--------------------------------------- REQUIREMENTS = "Bool_expression_for_reqs" #Optional From 6c322afd3217ba5026bb747b22a4a034d78d04aa Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 25 Jun 2010 15:22:51 +0200 Subject: [PATCH 21/25] feature #258: Updated VM tests --- src/scheduler/src/pool/test/VirtualMachineXMLTest.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc index 8b06d56910..fed583f708 100644 --- a/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc +++ b/src/scheduler/src/pool/test/VirtualMachineXMLTest.cc @@ -254,6 +254,7 @@ public: vector priorities; int hid; int rc; + map host_vms; CPPUNIT_ASSERT( vmp != 0 ); @@ -267,7 +268,7 @@ public: vm = vmp->get(0); CPPUNIT_ASSERT( vm != 0 ); - rc = vm->get_host(hid, hpool); + rc = vm->get_host(hid, hpool,host_vms,1); CPPUNIT_ASSERT( rc == -1 ); // get_host will iterate in reverse order the available hosts, and @@ -278,7 +279,7 @@ public: vm->add_host( 2 ); vm->add_host( 1 ); - rc = vm->get_host(hid, hpool); + rc = vm->get_host(hid, hpool,host_vms,1); CPPUNIT_ASSERT( rc == 0 ); CPPUNIT_ASSERT( hid == 4 ); @@ -293,7 +294,7 @@ public: vm->set_priorities(priorities); - rc = vm->get_host(hid, hpool); + rc = vm->get_host(hid, hpool,host_vms,1); CPPUNIT_ASSERT( rc == 0 ); CPPUNIT_ASSERT( hid == 5 ); From c7c08489a641c2578e24ac22893958bd696858a1 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 25 Jun 2010 15:35:42 +0200 Subject: [PATCH 22/25] feature #206: Include last_seq in VM XML render --- src/vm/VirtualMachine.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index bb16a570e6..02aee8b6f2 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1090,6 +1090,7 @@ string& VirtualMachine::to_xml(string& xml) const << "" << cpu << "" << "" << net_tx << "" << "" << net_rx << "" + << "" << last_seq << "" << vm_template.to_xml(template_xml); if ( hasHistory() ) From 9ea3ae7b385039d8faf4207ca34eb5ee4d93f35b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 25 Jun 2010 15:45:48 +0200 Subject: [PATCH 23/25] feature #206: Updated pool tests to handle sqlite and mysql --- src/pool/test/pool.cc | 53 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/pool/test/pool.cc b/src/pool/test/pool.cc index 923c5fa2a3..7449cc7bde 100644 --- a/src/pool/test/pool.cc +++ b/src/pool/test/pool.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -35,6 +36,7 @@ using namespace std; /* ************************************************************************* */ /* ************************************************************************* */ +bool mysql; class PoolTest : public CppUnit::TestFixture { @@ -65,7 +67,7 @@ public: { string db_name = "testdb"; - if (true) + if (mysql) { db = new MySqlDB("localhost","oneadmin","oneadmin",NULL); @@ -236,10 +238,59 @@ public: int main(int argc, char ** argv) { CppUnit::TextUi::TestRunner runner; + // Option flags + bool sqlite_flag = true; + bool log_flag = false; + + // Long options + const struct option long_opt[] = + { + { "sqlite", 0, NULL, 's'}, + { "mysql", 0, NULL, 'm'}, + { "log", 0, NULL, 'l'}, + { "help", 0, NULL, 'h'} + }; + + int c; + while ((c = getopt_long (argc, argv, "smlh", long_opt, NULL)) != -1) + switch (c) + { + case 'm': + sqlite_flag = false; + break; + case 'l': + log_flag = true; + break; + case 'h': + cout << "Options:\n"; + cout << " -h --help Show this help\n" + " -s --sqlite Run Sqlite tests (default)\n" + " -m --mysql Run MySQL tests\n" + " -l --log Keep the log file, test.log\n"; + return 0; + } NebulaLog::init_log_system(NebulaLog::FILE, Log::ERROR, "test.log"); + + if (sqlite_flag) + { + mysql = false; + NebulaLog::log("Test", Log::INFO, "Running Sqlite tests..."); + cout << "\nRunning Sqlite tests...\n"; + } + else + { + mysql = true; + NebulaLog::log("Test", Log::INFO, "Running MySQL tests..."); + cout << "\nRunning MySQL tests...\n"; + } + runner.addTest( PoolTest::suite() ); runner.run(); + + if (!log_flag) + remove("test.log"); + NebulaLog::finalize_log_system(); return 0; From 774c8e0d58978acea53bc6bdd83b6f770348fac3 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 25 Jun 2010 19:17:17 +0200 Subject: [PATCH 24/25] feature #200: spaces in oned.conf --- share/etc/oned.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/etc/oned.conf b/share/etc/oned.conf index ca63a8427b..2b31197cb1 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -66,13 +66,13 @@ MAC_PREFIX = "00:03" #******************************************************************************* # Image Repository Configuration #******************************************************************************* -# IMAGE_REPOSITORY_PATH: Define the path to the image repository, by default +# IMAGE_REPOSITORY_PATH: Define the path to the image repository, by default # is set to $ONE_LOCATION/var # # DEFAULT_IMAGE_TYPE: This can take values # OS Image file holding an operating system # CDROM Image file holding a CDROM -# DATABLOCK Image file holding a datablock, +# DATABLOCK Image file holding a datablock, # always created as an empty block # DEFAULT_DEVICE_PREFIX: This can be set to # hd IDE prefix @@ -81,7 +81,7 @@ MAC_PREFIX = "00:03" # vd KVM virtual disk #******************************************************************************* -#IMAGE_REPOSITORY_PATH = +#IMAGE_REPOSITORY_PATH = DEFAULT_IMAGE_TYPE = "OS" DEFAULT_DEVICE_PREFIX = "hd" From 1eed13a479f6956b039bb1b7367184d3505f5a57 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 25 Jun 2010 19:34:31 +0200 Subject: [PATCH 25/25] feature #200: Release acquired images --- src/dm/DispatchManagerActions.cc | 2 ++ src/dm/DispatchManagerStates.cc | 2 ++ src/vm/VirtualMachine.cc | 17 ++++++++--------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index 1d24990b50..b23eaa8fca 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -592,6 +592,8 @@ int DispatchManager::finalize( vm->release_network_leases(); + vm->release_disk_images(); + vm->log("DiM", Log::INFO, "New VM state is DONE."); break; diff --git a/src/dm/DispatchManagerStates.cc b/src/dm/DispatchManagerStates.cc index d1cb7c597e..7a94a2701d 100644 --- a/src/dm/DispatchManagerStates.cc +++ b/src/dm/DispatchManagerStates.cc @@ -117,6 +117,8 @@ void DispatchManager::done_action(int vid) vm->log("DiM", Log::INFO, "New VM state is DONE"); vm->release_network_leases(); + + vm->release_disk_images(); } else { diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index c8138af783..61238a222b 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -300,7 +300,7 @@ int VirtualMachine::insert(SqlDB * db) if ( rc != 0 ) { - goto error_leases; + goto error_leases; } // ------------------------------------------------------------------------ @@ -357,12 +357,11 @@ int VirtualMachine::insert(SqlDB * db) error_update: NebulaLog::log("ONE",Log::ERROR, "Can not update VM in the database"); vm_template.drop(db); - return -1; + goto error_common; error_template: NebulaLog::log("ONE",Log::ERROR, "Can not insert template in the database"); - release_network_leases(); - return -1; + goto error_common; error_leases: NebulaLog::log("ONE",Log::ERROR, "Could not get network lease for VM"); @@ -371,17 +370,18 @@ error_leases: error_images: NebulaLog::log("ONE",Log::ERROR, "Could not get disk image for VM"); - release_disk_images(); - return -1; + goto error_common; error_context: NebulaLog::log("ONE",Log::ERROR, "Could not parse CONTEXT for VM"); - release_network_leases(); - return -1; + goto error_common; error_requirements: NebulaLog::log("ONE",Log::ERROR, "Could not parse REQUIREMENTS for VM"); + +error_common: release_network_leases(); + release_disk_images(); return -1; } @@ -539,7 +539,6 @@ int VirtualMachine::parse_requirements() } return rc; ->>>>>>> master } /* ------------------------------------------------------------------------ */