|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] tools/xl: fix autoballoon regex
commit 2faeb4213d9b412836fe80e5685bfcccc51feb92
Author: Dmitry Isaykin <isaikin-dmitry@xxxxxxxxx>
AuthorDate: Fri Oct 1 15:24:16 2021 +0300
Commit: Ian Jackson <iwj@xxxxxxxxxxxxxx>
CommitDate: Tue Oct 12 14:40:14 2021 +0100
tools/xl: fix autoballoon regex
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.
Also add support for [tT] granularity suffix.
Also add support for memory fractions (i.e. '50%' or '1G+25%').
Signed-off-by: Dmitry Isaykin <isaikin-dmitry@xxxxxxxxx>
Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
tools/xl/xl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/xl/xl.c b/tools/xl/xl.c
index 4107d10fd4..f422f9fed5 100644
--- a/tools/xl/xl.c
+++ b/tools/xl/xl.c
@@ -80,14 +80,20 @@ static int auto_autoballoon(void)
if (!info)
return 1; /* default to on */
+#define SIZE_PATTERN "-?[0-9]+[bBkKmMgGtT]?"
+
ret = regcomp(®ex,
- "(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| )",
+ "(^| )dom0_mem=((|min:|max:)(" SIZE_PATTERN "|("
SIZE_PATTERN "\\+)?[0-9]{1,2}%),?)+($| )",
REG_NOSUB | REG_EXTENDED);
+
+#undef SIZE_PATTERN
+
if (ret)
return 1;
ret = regexec(®ex, info->commandline, 0, NULL, 0);
regfree(®ex);
+
return ret == REG_NOMATCH;
}
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |