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

[Xen-devel] [PATCH v4 08/53] xen/arch/x86/dom0_build.c: let custom parameter parsing routines return errno



Modify the custom parameter parsing routines in:

xen/arch/x86/dom0_build.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
V3:
- cosmetic changes (Jan Beulich)
- dont modify option value in parsing function
---
 xen/arch/x86/dom0_build.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
index 0c125e61eb..f616b99ddc 100644
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -47,7 +47,8 @@ static long __init parse_amt(const char *s, const char **ps)
     long pages = parse_size_and_unit((*s == '-') ? s+1 : s, ps) >> PAGE_SHIFT;
     return (*s == '-') ? -pages : pages;
 }
-static void __init parse_dom0_mem(const char *s)
+
+static int __init parse_dom0_mem(const char *s)
 {
     do {
         if ( !strncmp(s, "min:", 4) )
@@ -57,13 +58,15 @@ static void __init parse_dom0_mem(const char *s)
         else
             dom0_nrpages = parse_amt(s, &s);
     } while ( *s++ == ',' );
+
+    return *s ? -EINVAL : 0;
 }
 custom_param("dom0_mem", parse_dom0_mem);
 
 static unsigned int __initdata opt_dom0_max_vcpus_min = 1;
 static unsigned int __initdata opt_dom0_max_vcpus_max = UINT_MAX;
 
-static void __init parse_dom0_max_vcpus(const char *s)
+static int __init parse_dom0_max_vcpus(const char *s)
 {
     if ( *s == '-' )                   /* -M */
         opt_dom0_max_vcpus_max = simple_strtoul(s + 1, &s, 0);
@@ -77,6 +80,8 @@ static void __init parse_dom0_max_vcpus(const char *s)
         else if ( *s++ == '-' && *s ) /* N-M */
             opt_dom0_max_vcpus_max = simple_strtoul(s, &s, 0);
     }
+
+    return *s ? -EINVAL : 0;
 }
 custom_param("dom0_max_vcpus", parse_dom0_max_vcpus);
 
@@ -85,7 +90,7 @@ static __initdata unsigned int dom0_pxms[MAX_NUMNODES] =
     { [0 ... MAX_NUMNODES - 1] = ~0 };
 static __initdata bool dom0_affinity_relaxed;
 
-static void __init parse_dom0_nodes(const char *s)
+static int __init parse_dom0_nodes(const char *s)
 {
     do {
         if ( isdigit(*s) )
@@ -103,6 +108,8 @@ static void __init parse_dom0_nodes(const char *s)
         else
             break;
     } while ( ++dom0_nr_pxms < ARRAY_SIZE(dom0_pxms) && *s++ == ',' );
+
+    return *s ? -EINVAL : 0;
 }
 custom_param("dom0_nodes", parse_dom0_nodes);
 
@@ -183,25 +190,30 @@ bool __initdata dom0_pvh;
  *  - pvh               Create a PVHv2 Dom0.
  *  - shadow            Use shadow paging for Dom0.
  */
-static void __init parse_dom0_param(char *s)
+static int __init parse_dom0_param(const char *s)
 {
-    char *ss;
+    const char *ss;
+    int rc = 0;
 
     do {
 
         ss = strchr(s, ',');
-        if ( ss )
-            *ss = '\0';
+        if ( !ss )
+            ss = strchr(s, '\0');
 
-        if ( !strcmp(s, "pvh") )
+        if ( !strncmp(s, "pvh", ss - s) )
             dom0_pvh = true;
 #ifdef CONFIG_SHADOW_PAGING
-        else if ( !strcmp(s, "shadow") )
+        else if ( !strncmp(s, "shadow", ss - s) )
             opt_dom0_shadow = true;
 #endif
+        else
+            rc = -EINVAL;
 
         s = ss + 1;
-    } while ( ss );
+    } while ( *ss );
+
+    return rc;
 }
 custom_param("dom0", parse_dom0_param);
 
-- 
2.12.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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