Commit 618b2c8d authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Ingo Molnar

xen: make sysfs files behave as their names suggest

1: make "target_kb" only accept and produce a memory size in kilobytes.
2: add a second "target" file which produces output in bytes, and will accept
   memparse input (scaled bytes)

This fixes the rather irritating problem that writing the same value
read back into target_kb would end up shrinking the domain by a factor
of 1024, with generally bad results.
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stable Kernel <stable@kernel.org>
Cc: "dan.magenheimer@oracle.com" <dan.magenheimer@oracle.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent bf3647c4
...@@ -498,7 +498,7 @@ static ssize_t store_target_kb(struct sys_device *dev, ...@@ -498,7 +498,7 @@ static ssize_t store_target_kb(struct sys_device *dev,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
target_bytes = memparse(buf, &endchar); target_bytes = simple_strtoull(buf, &endchar, 0) * 1024;
balloon_set_new_target(target_bytes >> PAGE_SHIFT); balloon_set_new_target(target_bytes >> PAGE_SHIFT);
...@@ -508,8 +508,39 @@ static ssize_t store_target_kb(struct sys_device *dev, ...@@ -508,8 +508,39 @@ static ssize_t store_target_kb(struct sys_device *dev,
static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR,
show_target_kb, store_target_kb); show_target_kb, store_target_kb);
static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr,
char *buf)
{
return sprintf(buf, "%llu\n",
(u64)balloon_stats.target_pages << PAGE_SHIFT);
}
static ssize_t store_target(struct sys_device *dev,
struct sysdev_attribute *attr,
const char *buf,
size_t count)
{
char *endchar;
unsigned long long target_bytes;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
target_bytes = memparse(buf, &endchar);
balloon_set_new_target(target_bytes >> PAGE_SHIFT);
return count;
}
static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR,
show_target, store_target);
static struct sysdev_attribute *balloon_attrs[] = { static struct sysdev_attribute *balloon_attrs[] = {
&attr_target_kb, &attr_target_kb,
&attr_target,
}; };
static struct attribute *balloon_info_attrs[] = { static struct attribute *balloon_info_attrs[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment