[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 04/12] xen: add a generic flags field to parameter definitions



In preparation for domain specific parameters add a flags field to
struct kernel_param. Add a common flag definition for support of
changing the related parameter at runtime (in case of domains while
the domain is already running in contrast to domain creation time).

As other flags will be scope specific add a generic check function
pointer to struct parse_data which will be called by parameter parsing
to verify the parameter is allowed on the specified instance.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/common/kernel.c    | 15 +++++++++++++--
 xen/include/xen/init.h | 28 ++++++++++++++++------------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index f7f4e0dbff..0d3d7f6135 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -22,6 +22,7 @@ struct parse_data {
     enum param_scope scope;
     const struct kernel_param *start;
     const struct kernel_param *end;
+    int (*check)(void *instance, unsigned int flags);
 };
 
 enum system_state system_state = SYS_STATE_early_boot;
@@ -124,7 +125,10 @@ static int parse_params(const char *cmdline, const struct 
parse_data *data,
                 {
                     found = true;
                     optval[-1] = '=';
-                    rctmp = param->par.call(q, instance);
+                    rctmp = data->check
+                            ? data->check(instance, param->flags) : 0;
+                    if ( !rctmp )
+                        rctmp = param->par.call(q, instance);
                     optval[-1] = '\0';
                     if ( !rc )
                         rc = rctmp;
@@ -132,7 +136,14 @@ static int parse_params(const char *cmdline, const struct 
parse_data *data,
                 continue;
             }
 
-            rctmp = 0;
+            rctmp = data->check ? data->check(instance, param->flags) : 0;
+            if ( rctmp )
+            {
+                if ( !rc )
+                    rc = rctmp;
+                continue;
+            }
+
             found = true;
             ptr = (void *)((uint64_t)param->par.var + (uint64_t)instance);
             switch ( param->type )
diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h
index b04534c11a..3975964ee8 100644
--- a/xen/include/xen/init.h
+++ b/xen/include/xen/init.h
@@ -88,6 +88,8 @@ struct kernel_param {
     } type;
     unsigned int len;
     enum param_scope scope;
+    unsigned int flags;
+#define PARAM_FLAG_RUNTIME    0x80000000
     union {
         void *var;
         int (*func)(const char *);
@@ -107,56 +109,58 @@ extern const struct kernel_param __param_start[], 
__param_end[];
     __attribute__((__aligned__(1))) char
 #define __kparam          __param(__initsetup)
 
-#define def_custom_param(_name, _scope, _func) \
+#define def_custom_param(_name, _scope, _flags, _func) \
     { .name = _name, \
       .type = OPT_CUSTOM, \
       .scope = _scope, \
+      .flags = _flags, \
       .par.func = _func }
-#define def_var_param(_name, _type, _scope, _var) \
+#define def_var_param(_name, _type, _scope, _flags, _var) \
     { .name = _name, \
       .type = _type, \
       .len = sizeof(_var), \
       .scope = _scope, \
+      .flags = _flags, \
       .par.var = &_var }
 
 #define custom_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        def_custom_param(__setup_str_##_var, SCOPE_GLOBAL, _var)
+        def_custom_param(__setup_str_##_var, SCOPE_GLOBAL, 0, _var)
 #define boolean_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        def_var_param(__setup_str_##_var, OPT_BOOL, SCOPE_GLOBAL, _var)
+        def_var_param(__setup_str_##_var, OPT_BOOL, SCOPE_GLOBAL, 0, _var)
 #define integer_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        def_var_param(__setup_str_##_var, OPT_UINT, SCOPE_GLOBAL, _var)
+        def_var_param(__setup_str_##_var, OPT_UINT, SCOPE_GLOBAL, 0, _var)
 #define size_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        def_var_param(__setup_str_##_var, OPT_SIZE, SCOPE_GLOBAL, _var)
+        def_var_param(__setup_str_##_var, OPT_SIZE, SCOPE_GLOBAL, 0, _var)
 #define string_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
     __kparam __setup_##_var = \
-        def_var_param(__setup_str_##_var, OPT_STR, SCOPE_GLOBAL, _var)
+        def_var_param(__setup_str_##_var, OPT_STR, SCOPE_GLOBAL, 0, _var)
 
 #define __rtparam         __param(__dataparam)
 
 #define custom_runtime_only_param(_name, _var) \
     __rtparam __rtpar_##_var = \
-        def_custom_param(_name, SCOPE_GLOBAL, _var)
+        def_custom_param(_name, SCOPE_GLOBAL, 0, _var)
 #define boolean_runtime_only_param(_name, _var) \
     __rtparam __rtpar_##_var = \
-        def_var_param(_name, OPT_BOOL, SCOPE_GLOBAL, _var)
+        def_var_param(_name, OPT_BOOL, SCOPE_GLOBAL, 0, _var)
 #define integer_runtime_only_param(_name, _var) \
     __rtparam __rtpar_##_var = \
-        def_var_param(_name, OPT_UINT, SCOPE_GLOBAL, _var)
+        def_var_param(_name, OPT_UINT, SCOPE_GLOBAL, 0, _var)
 #define size_runtime_only_param(_name, _var) \
     __rtparam __rtpar_##_var = \
-        def_var_param(_name, OPT_SIZE, SCOPE_GLOBAL, _var)
+        def_var_param(_name, OPT_SIZE, SCOPE_GLOBAL, 0, _var)
 #define string_runtime_only_param(_name, _var) \
     __rtparam __rtpar_##_var = \
-        def_var_param(_name, OPT_STR, SCOPE_GLOBAL, _var)
+        def_var_param(_name, OPT_STR, SCOPE_GLOBAL, 0, _var)
 
 #define custom_runtime_param(_name, _var) \
     custom_param(_name, _var); \
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.