[Xen-devel] [PATCH v2 6/6] xen: add runtime parameter reading support to hypfs

Juergen Gross posted 6 patches 6 years, 4 months ago
There is a newer version of this series
[Xen-devel] [PATCH v2 6/6] xen: add runtime parameter reading support to hypfs
Posted by Juergen Gross 6 years, 4 months ago
Add support to read values of hypervisor runtime parameters via the
hypervisor file system for all unsigned integer type runtime parameters.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 docs/misc/hypfs-paths.pandoc |  9 +++++++++
 xen/common/kernel.c          | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc
index 81353546ef..c12014505e 100644
--- a/docs/misc/hypfs-paths.pandoc
+++ b/docs/misc/hypfs-paths.pandoc
@@ -102,3 +102,12 @@ hypervisor.
 #### /buildinfo/config = STRING
 
 The contents of the `xen/.config` file at the time of the hypervisor build.
+
+#### /params/
+
+A directory of runtime parameters (those can be set via xl set-parameters).
+
+#### /params/*
+
+The single parameters. The description of the different parameters can be
+found in `docs/misc/xen-command-line.pandoc`.
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 760917dab5..e2e6d171a7 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -7,6 +7,7 @@
 #include <xen/init.h>
 #include <xen/lib.h>
 #include <xen/errno.h>
+#include <xen/hypfs.h>
 #include <xen/version.h>
 #include <xen/sched.h>
 #include <xen/paging.h>
@@ -320,6 +321,44 @@ int cmdline_strcmp(const char *frag, const char *name)
     }
 }
 
+static struct hypfs_dir hypfs_params = {
+    .list = LIST_HEAD_INIT(hypfs_params.list),
+};
+
+static int __init runtime_param_hypfs_add(void)
+{
+    const struct kernel_param *param;
+    int ret;
+
+    ret = hypfs_new_dir(&hypfs_root, "params", &hypfs_params);
+    BUG_ON(ret);
+
+    for ( param = __param_start; param < __param_end; param++ )
+    {
+        switch ( param->type )
+        {
+        case OPT_UINT:
+            if ( param->len == sizeof(unsigned int) )
+                ret = hypfs_new_entry_uint(&hypfs_params, param->name,
+                                           (unsigned int *)(param->par.var));
+            break;
+
+        case OPT_STR:
+            ret = hypfs_new_entry_uint(&hypfs_params, param->name,
+                                       param->par.var);
+            break;
+
+        default:
+            break;
+        }
+
+        BUG_ON(ret);
+    }
+
+    return 0;
+}
+__initcall(runtime_param_hypfs_add);
+
 unsigned int tainted;
 
 /**
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 6/6] xen: add runtime parameter reading support to hypfs
Posted by Jan Beulich 6 years, 2 months ago
On 02.10.2019 13:20, Juergen Gross wrote:
> Add support to read values of hypervisor runtime parameters via the
> hypervisor file system for all unsigned integer type runtime parameters.

What about string ones (which you seem to handle in the code,
but see also there)?

> @@ -320,6 +321,44 @@ int cmdline_strcmp(const char *frag, const char *name)
>      }
>  }
>  
> +static struct hypfs_dir hypfs_params = {
> +    .list = LIST_HEAD_INIT(hypfs_params.list),
> +};
> +
> +static int __init runtime_param_hypfs_add(void)
> +{
> +    const struct kernel_param *param;
> +    int ret;
> +
> +    ret = hypfs_new_dir(&hypfs_root, "params", &hypfs_params);
> +    BUG_ON(ret);
> +
> +    for ( param = __param_start; param < __param_end; param++ )
> +    {
> +        switch ( param->type )
> +        {
> +        case OPT_UINT:
> +            if ( param->len == sizeof(unsigned int) )
> +                ret = hypfs_new_entry_uint(&hypfs_params, param->name,
> +                                           (unsigned int *)(param->par.var));

Stray pair or parentheses. I also don't see the need for the cast,
with the "var" union member being "void *".

> +            break;
> +
> +        case OPT_STR:
> +            ret = hypfs_new_entry_uint(&hypfs_params, param->name,
> +                                       param->par.var);

hypfs_new_entry_string()?

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 6/6] xen: add runtime parameter reading support to hypfs
Posted by Jürgen Groß 6 years, 2 months ago
On 12.11.19 15:28, Jan Beulich wrote:
> On 02.10.2019 13:20, Juergen Gross wrote:
>> Add support to read values of hypervisor runtime parameters via the
>> hypervisor file system for all unsigned integer type runtime parameters.
> 
> What about string ones (which you seem to handle in the code,
> but see also there)?

Oh, right, this was a late addition.

> 
>> @@ -320,6 +321,44 @@ int cmdline_strcmp(const char *frag, const char *name)
>>       }
>>   }
>>   
>> +static struct hypfs_dir hypfs_params = {
>> +    .list = LIST_HEAD_INIT(hypfs_params.list),
>> +};
>> +
>> +static int __init runtime_param_hypfs_add(void)
>> +{
>> +    const struct kernel_param *param;
>> +    int ret;
>> +
>> +    ret = hypfs_new_dir(&hypfs_root, "params", &hypfs_params);
>> +    BUG_ON(ret);
>> +
>> +    for ( param = __param_start; param < __param_end; param++ )
>> +    {
>> +        switch ( param->type )
>> +        {
>> +        case OPT_UINT:
>> +            if ( param->len == sizeof(unsigned int) )
>> +                ret = hypfs_new_entry_uint(&hypfs_params, param->name,
>> +                                           (unsigned int *)(param->par.var));
> 
> Stray pair or parentheses. I also don't see the need for the cast,
> with the "var" union member being "void *".

Right, will drop the cast.

> 
>> +            break;
>> +
>> +        case OPT_STR:
>> +            ret = hypfs_new_entry_uint(&hypfs_params, param->name,
>> +                                       param->par.var);
> 
> hypfs_new_entry_string()?

Yes.


Juergen

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