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

[Xen-devel] [PATCH 07/12] xen: add domain specific parameter support



Add the framework for being able to define cpupool specific parameters.
This includes the needed macros for defining a parameter and the
minimal set of functions for doing parameter parsing.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/common/cpupool.c    | 10 ++++++++++
 xen/common/kernel.c     | 12 ++++++++++++
 xen/common/sysctl.c     | 14 ++++++++++++++
 xen/include/xen/init.h  | 23 +++++++++++++++++++++++
 xen/include/xen/lib.h   |  2 ++
 xen/include/xen/sched.h |  1 +
 6 files changed, 62 insertions(+)

diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c
index 1e8edcbd57..0a9f875602 100644
--- a/xen/common/cpupool.c
+++ b/xen/common/cpupool.c
@@ -808,6 +808,16 @@ static int __init cpupool_presmp_init(void)
 }
 presmp_initcall(cpupool_presmp_init);
 
+int cpupool_check_parflags(void *instance, unsigned int flags)
+{
+    struct cpupool *c = instance;
+
+    if ( !(flags & PARAM_FLAG_RUNTIME) && (c->n_dom != 0) )
+        return -EBUSY;
+
+    return 0;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index d0b3af1453..81155d5ebe 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -222,6 +222,13 @@ static const struct parse_data runtime_parse_data = {
     .end    = __param_end,
 };
 
+static const struct parse_data cpupool_parse_data = {
+    .scope = SCOPE_CPUPOOL,
+    .start = __param_start,
+    .end   = __param_end,
+    .check = cpupool_check_parflags,
+};
+
 static const struct parse_data domain_parse_data = {
     .scope = SCOPE_DOMAIN,
     .start = __param_start,
@@ -239,6 +246,11 @@ int runtime_parse(const char *line)
     return parse_params(line, &runtime_parse_data, NULL);
 }
 
+int cpupool_param_parse(struct cpupool *c, const char *line)
+{
+    return parse_params(line, &cpupool_parse_data, c);
+}
+
 int domain_param_parse(struct domain *d, const char *line)
 {
     return parse_params(line, &domain_parse_data, d);
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index f10cd279f7..575248301e 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -499,6 +499,20 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
                 ret = op->u.set_parameter.instance
                       ? -EINVAL : runtime_parse(params);
                 break;
+            case XEN_SYSCTL_SETPAR_SCOPE_CPUPOOL:
+            {
+                struct cpupool *c;
+
+                c = cpupool_get_by_id(op->u.set_parameter.instance);
+                if ( c == NULL )
+                    ret = -ESRCH;
+                else
+                {
+                    ret = cpupool_param_parse(c, params);
+                    cpupool_put(c);
+                }
+                break;
+            }
             default:
                 ret = -EINVAL;
                 break;
diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h
index 13cf5214b3..598ae0b5d4 100644
--- a/xen/include/xen/init.h
+++ b/xen/include/xen/init.h
@@ -54,6 +54,7 @@
 
 #ifndef __ASSEMBLY__
 
+struct cpupool;
 struct domain;
 
 /*
@@ -77,6 +78,7 @@ void do_initcalls(void);
  */
 enum param_scope {
     SCOPE_GLOBAL,
+    SCOPE_CPUPOOL,
     SCOPE_DOMAIN
 };
 
@@ -96,6 +98,7 @@ struct kernel_param {
     union {
         void *var;
         int (*func)(const char *);
+        int (*func_cpupool)(const char *, struct cpupool *);
         int (*func_domain)(const char *, struct domain *);
         int (*call)(const char *, void *);
     } par;
@@ -182,6 +185,26 @@ extern const struct kernel_param __param_start[], 
__param_end[];
     string_param(_name, _var); \
     string_runtime_only_param(_name, _var)
 
+#define custom_cpupool_param(_name, _flags, _var) \
+    __rtparam __cpupool_par_##_var = \
+        def_custom_param(_name, SCOPE_CPUPOOL, _flags, func_cpupool, _var)
+#define boolean_cpupool_param(_name, _flags, _var) \
+    __rtparam __cpupool_par_##_var = \
+        def_var_param(_name, OPT_BOOL, SCOPE_CPUPOOL, _flags, \
+                      (struct cpupool *)NULL->_var)
+#define integer_cpupool_param(_name, _flags, _var) \
+    __rtparam __cpupool_par_##_var = \
+        def_var_param(_name, OPT_UINT, SCOPE_CPUPOOL, _flags, \
+                      (struct cpupool *)NULL->_var)
+#define size_cpupool_param(_name, _flags, _var) \
+    __rtparam __cpupool_par_##_var = \
+        def_var_param(_name, OPT_SIZE, SCOPE_CPUPOOL, _flags, \
+                      (struct cpupool *)NULL->_var)
+#define string_cpupool_param(_name, _flags, _var) \
+    __rtparam __cpupool_par_##_var = \
+        def_var_param(_name, OPT_STR, SCOPE_CPUPOOL, _flags, \
+                      (struct cpupool *)NULL->_var)
+
 #define custom_domain_param(_name, _flags, _var) \
     __rtparam __domain_par_##_var = \
         def_custom_param(_name, SCOPE_DOMAIN, _flags, func_domain, _var)
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 7ba5929ed5..17f60607ca 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -66,10 +66,12 @@
 
 #define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1))
 
+struct cpupool;
 struct domain;
 
 void cmdline_parse(const char *cmdline);
 int runtime_parse(const char *line);
+int cpupool_param_parse(struct cpupool *c, const char *line);
 int domain_param_parse(struct domain *d, const char *line);
 int parse_bool(const char *s, const char *e);
 
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 0ba80cb1a8..97f838b7c0 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -919,6 +919,7 @@ int cpupool_move_domain(struct domain *d, struct cpupool 
*c);
 int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op);
 void schedule_dump(struct cpupool *c);
 extern void dump_runq(unsigned char key);
+int cpupool_check_parflags(void *instance, unsigned int flags);
 
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi);
 
-- 
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®.