diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2009-01-28 19:50:20 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-29 07:20:36 -0500 |
commit | 618b2c8db24522ae273d8299c6a936ea13793c4d (patch) | |
tree | b0f5f9e03ee56fb85755db24877736e97b3989af /drivers/xen | |
parent | bf3647c44bc76c43c4b2ebb4c37a559e899ac70e (diff) |
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: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stable Kernel <stable@kernel.org>
Cc: "dan.magenheimer@oracle.com" <dan.magenheimer@oracle.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/balloon.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 2ba8f95516a0..efa4b363ce72 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -498,7 +498,7 @@ static ssize_t store_target_kb(struct sys_device *dev, | |||
498 | if (!capable(CAP_SYS_ADMIN)) | 498 | if (!capable(CAP_SYS_ADMIN)) |
499 | return -EPERM; | 499 | return -EPERM; |
500 | 500 | ||
501 | target_bytes = memparse(buf, &endchar); | 501 | target_bytes = simple_strtoull(buf, &endchar, 0) * 1024; |
502 | 502 | ||
503 | balloon_set_new_target(target_bytes >> PAGE_SHIFT); | 503 | balloon_set_new_target(target_bytes >> PAGE_SHIFT); |
504 | 504 | ||
@@ -508,8 +508,39 @@ static ssize_t store_target_kb(struct sys_device *dev, | |||
508 | static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, | 508 | static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, |
509 | show_target_kb, store_target_kb); | 509 | show_target_kb, store_target_kb); |
510 | 510 | ||
511 | |||
512 | static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr, | ||
513 | char *buf) | ||
514 | { | ||
515 | return sprintf(buf, "%llu\n", | ||
516 | (u64)balloon_stats.target_pages << PAGE_SHIFT); | ||
517 | } | ||
518 | |||
519 | static ssize_t store_target(struct sys_device *dev, | ||
520 | struct sysdev_attribute *attr, | ||
521 | const char *buf, | ||
522 | size_t count) | ||
523 | { | ||
524 | char *endchar; | ||
525 | unsigned long long target_bytes; | ||
526 | |||
527 | if (!capable(CAP_SYS_ADMIN)) | ||
528 | return -EPERM; | ||
529 | |||
530 | target_bytes = memparse(buf, &endchar); | ||
531 | |||
532 | balloon_set_new_target(target_bytes >> PAGE_SHIFT); | ||
533 | |||
534 | return count; | ||
535 | } | ||
536 | |||
537 | static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR, | ||
538 | show_target, store_target); | ||
539 | |||
540 | |||
511 | static struct sysdev_attribute *balloon_attrs[] = { | 541 | static struct sysdev_attribute *balloon_attrs[] = { |
512 | &attr_target_kb, | 542 | &attr_target_kb, |
543 | &attr_target, | ||
513 | }; | 544 | }; |
514 | 545 | ||
515 | static struct attribute *balloon_info_attrs[] = { | 546 | static struct attribute *balloon_info_attrs[] = { |