aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/lib.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-11-01 11:18:29 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-11-01 11:18:29 +0000
commit7ffcc43b02744f2ec9a064635ff09ea17c0a7253 (patch)
tree0731809d2480fa9813c11b193335e6aa144d9e9f /xen/common/lib.c
parentaeade7ad12cc2efefe88d19fb03a62c263aae885 (diff)
downloadxen-7ffcc43b02744f2ec9a064635ff09ea17c0a7253.tar.gz
xen-7ffcc43b02744f2ec9a064635ff09ea17c0a7253.tar.bz2
xen-7ffcc43b02744f2ec9a064635ff09ea17c0a7253.zip
[XEN] Extend dom0_mem syntax to support min/max clamps.
dom0_mem=[min:<min_amt>,][max:<max_amt>,][<amt>] <min_amt>: The minimum amount of memory which should be allocated for dom0. <max_amt>: The maximum amount of memory which should be allocated for dom0. <amt>: The precise amount of memory to allocate for dom0. Notes: 1. <amt> is clamped from below by <min_amt> and from above by available memory and <max_amt> 2. <min_amt> is clamped from above by available memory and <max_amt> 3. <min_amt> is ignored if it is greater than <max_amt> 4. If <amt> is not specified, it is calculated as follows: "All of memory is allocated to domain 0, minus 1/16th which is reserved for uses such as DMA buffers (the reservation is clamped to 128MB)." Each value can be specified as positive or negative: If +ve: The specified amount is an absolute value. If -ve: The specified amount is subtracted from total available memory. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/common/lib.c')
-rw-r--r--xen/common/lib.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/xen/common/lib.c b/xen/common/lib.c
index 408e8eefe6..0eb58f19d2 100644
--- a/xen/common/lib.c
+++ b/xen/common/lib.c
@@ -439,21 +439,28 @@ s64 __moddi3(s64 a, s64 b)
#endif /* BITS_PER_LONG == 32 */
-unsigned long long parse_size_and_unit(char *s)
+unsigned long long parse_size_and_unit(const char *s, char **ps)
{
- unsigned long long ret = simple_strtoull(s, &s, 0);
+ unsigned long long ret = simple_strtoull(s, (char **)&s, 0);
switch (*s) {
case 'G': case 'g':
ret <<= 10;
case 'M': case 'm':
ret <<= 10;
- case 'K': case 'k': default:
+ case 'K': case 'k':
ret <<= 10;
case 'B': case 'b':
+ s++;
+ break;
+ default:
+ ret <<= 10; /* default to kB */
break;
}
+ if (ps != NULL)
+ *ps = (char *)s;
+
return ret;
}