Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 113230
b: refs/heads/master
c: 167e6cf
h: refs/heads/master
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and Ingo Molnar committed Jul 28, 2008
1 parent 5eee86a commit 1a8837d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a403e45c3b678211ee3b7225dbb924921fb5ddd3
refs/heads/master: 167e6cf62979df03513898966f9227847d192327
27 changes: 12 additions & 15 deletions trunk/drivers/xen/balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

#define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))

#define BALLOON_CLASS_NAME "memory"
#define BALLOON_CLASS_NAME "xen_memory"

struct balloon_stats {
/* We aim for 'current allocation' == 'target allocation'. */
Expand Down Expand Up @@ -588,12 +588,13 @@ static void balloon_release_driver_page(struct page *page)
}


#define BALLOON_SHOW(name, format, args...) \
static ssize_t show_##name(struct sys_device *dev, \
char *buf) \
{ \
return sprintf(buf, format, ##args); \
} \
#define BALLOON_SHOW(name, format, args...) \
static ssize_t show_##name(struct sys_device *dev, \
struct sysdev_attribute *attr, \
char *buf) \
{ \
return sprintf(buf, format, ##args); \
} \
static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL)

BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
Expand All @@ -604,7 +605,8 @@ BALLOON_SHOW(hard_limit_kb,
(balloon_stats.hard_limit!=~0UL) ? PAGES2KB(balloon_stats.hard_limit) : 0);
BALLOON_SHOW(driver_kb, "%lu\n", PAGES2KB(balloon_stats.driver_pages));

static ssize_t show_target_kb(struct sys_device *dev, char *buf)
static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr,
char *buf)
{
return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
}
Expand All @@ -614,19 +616,14 @@ static ssize_t store_target_kb(struct sys_device *dev,
const char *buf,
size_t count)
{
char memstring[64], *endchar;
char *endchar;
unsigned long long target_bytes;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

if (count <= 1)
return -EBADMSG; /* runt */
if (count > sizeof(memstring))
return -EFBIG; /* too long */
strcpy(memstring, buf);
target_bytes = memparse(buf, &endchar);

target_bytes = memparse(memstring, &endchar);
balloon_set_new_target(target_bytes >> PAGE_SHIFT);

return count;
Expand Down

0 comments on commit 1a8837d

Please sign in to comment.