[PATCH v2] tools/xl: fix autoballoon regex

Dmitry Isaikin posted 1 patch 2 years, 7 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
tools/xl/xl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] tools/xl: fix autoballoon regex
Posted by Dmitry Isaikin 2 years, 7 months ago
From: Dmitry Isaykin <isaikin-dmitry@yandex.ru>

This regex is used for auto-balloon mode detection based on Xen command line.

The case of specifying a negative size was handled incorrectly.
From misc/xen-command-line documentation:

    dom0_mem (x86)
    = List of ( min:<sz> | max:<sz> | <sz> )

    If a size is positive, it represents an absolute value.
    If a size is negative, it is subtracted from the total available memory.

Signed-off-by: Dmitry Isaykin <isaikin-dmitry@yandex.ru>
---
Changes in v2:
- add missing Signed-off-by tag
---
 tools/xl/xl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/xl/xl.c b/tools/xl/xl.c
index 4107d10fd4..a9f7e769fd 100644
--- a/tools/xl/xl.c
+++ b/tools/xl/xl.c
@@ -81,7 +81,7 @@ static int auto_autoballoon(void)
         return 1; /* default to on */
 
     ret = regcomp(&regex,
-                  "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
+                  "(^| )dom0_mem=((|min:|max:)-?[0-9]+[bBkKmMgG]?,?)+($| )",
                   REG_NOSUB | REG_EXTENDED);
     if (ret)
         return 1;
-- 
2.33.0


Re: [PATCH v2] tools/xl: fix autoballoon regex
Posted by Jan Beulich 2 years, 7 months ago
On 16.09.2021 11:34, Dmitry Isaikin wrote:
> --- a/tools/xl/xl.c
> +++ b/tools/xl/xl.c
> @@ -81,7 +81,7 @@ static int auto_autoballoon(void)
>          return 1; /* default to on */
>  
>      ret = regcomp(&regex,
> -                  "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
> +                  "(^| )dom0_mem=((|min:|max:)-?[0-9]+[bBkKmMgG]?,?)+($| )",

Wouldn't this be a good opportunity to also add [tT] to the list
of permitted granularity suffixes? The hypervisor's
parse_size_and_unit() has been supporting this for quite some
time ...

Jan