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

[Xen-devel] [PATCH v3 26/52] xen/common/kexec.c: let custom parameter parsing routines return errno



Modify the custom parameter parsing routines in:

xen/common/kexec.c

to indicate whether the parameter value was parsed successfully.

Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/common/kexec.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/xen/common/kexec.c b/xen/common/kexec.c
index a52c30ba1e..fcc68bd4d8 100644
--- a/xen/common/kexec.c
+++ b/xen/common/kexec.c
@@ -102,9 +102,10 @@ static void *crash_heap_current = NULL, *crash_heap_end = 
NULL;
  * < and below are synonyomous, the latter being useful for grub2 systems
  * which would otherwise require escaping of the < option
  */
-static void __init parse_crashkernel(const char *str)
+static int __init parse_crashkernel(const char *str)
 {
     const char *cur;
+    int rc = 0;
 
     if ( strchr(str, ':' ) )
     {
@@ -116,6 +117,7 @@ static void __init parse_crashkernel(const char *str)
                 printk(XENLOG_WARNING "crashkernel: too many ranges\n");
                 cur = NULL;
                 str = strpbrk(str, "@,<");
+                rc = -EINVAL;
                 break;
             }
 
@@ -126,6 +128,7 @@ static void __init parse_crashkernel(const char *str)
             if ( *str != '-' )
             {
                 printk(XENLOG_WARNING "crashkernel: '-' expected\n");
+                rc = -EINVAL;
                 break;
             }
 
@@ -137,6 +140,7 @@ static void __init parse_crashkernel(const char *str)
                 if ( ranges[idx].end <= ranges[idx].start )
                 {
                     printk(XENLOG_WARNING "crashkernel: end <= start\n");
+                    rc = -EINVAL;
                     break;
                 }
             }
@@ -146,6 +150,7 @@ static void __init parse_crashkernel(const char *str)
             if ( *str != ':' )
             {
                 printk(XENLOG_WARNING "crashkernel: ':' expected\n");
+                rc = -EINVAL;
                 break;
             }
 
@@ -169,10 +174,18 @@ static void __init parse_crashkernel(const char *str)
         else if ( !strncmp(str, ",below=", 7) )
             kexec_crash_area_limit = parse_size_and_unit(cur = str + 7, &str);
         else
+        {
             printk(XENLOG_WARNING "crashkernel: '%s' ignored\n", str);
+            rc = -EINVAL;
+        }
     }
     if ( cur && cur == str )
+    {
         printk(XENLOG_WARNING "crashkernel: memory value expected\n");
+        rc = -EINVAL;
+    }
+
+    return rc;
 }
 custom_param("crashkernel", parse_crashkernel);
 
@@ -186,7 +199,7 @@ custom_param("crashkernel", parse_crashkernel);
  * - all will allocate additional structures such as domain and vcpu structs
  *       low so the crash kernel can perform an extended analysis of state.
  */
-static void __init parse_low_crashinfo(const char * str)
+static int __init parse_low_crashinfo(const char *str)
 {
 
     if ( !strlen(str) )
@@ -202,7 +215,10 @@ static void __init parse_low_crashinfo(const char * str)
     {
         printk("Unknown low_crashinfo parameter '%s'.  Defaulting to min.\n", 
str);
         low_crashinfo_mode = LOW_CRASHINFO_MIN;
+        return -EINVAL;
     }
+
+    return 0;
 }
 custom_param("low_crashinfo", parse_low_crashinfo);
 
@@ -212,19 +228,25 @@ custom_param("low_crashinfo", parse_low_crashinfo);
  *
  * <addr> will be rounded down to the nearest power of two.  Defaults to 64G
  */
-static void __init parse_crashinfo_maxaddr(const char * str)
+static int __init parse_crashinfo_maxaddr(const char *str)
 {
     u64 addr;
+    const char *q;
 
     /* if low_crashinfo_mode is unset, default to min. */
     if ( low_crashinfo_mode == LOW_CRASHINFO_INVALID )
         low_crashinfo_mode = LOW_CRASHINFO_MIN;
 
-    if ( (addr = parse_size_and_unit(str, NULL)) )
+    if ( (addr = parse_size_and_unit(str, &q)) )
         crashinfo_maxaddr = addr;
     else
+    {
         printk("Unable to parse crashinfo_maxaddr. Defaulting to 
%"PRIpaddr"\n",
                crashinfo_maxaddr);
+        return -EINVAL;
+    }
+
+    return *q ? -EINVAL : 0;
 }
 custom_param("crashinfo_maxaddr", parse_crashinfo_maxaddr);
 
-- 
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®.