lkml.org 
[lkml]   [2013]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 1/2] xen/balloon: Notify a host about a guest memory size limit
Date
Notify a host about a guest memory size limit.

Idea of this patch was discussed with Ian Campbell and Ian Jackson.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
drivers/xen/balloon.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index a56776d..856661f 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -65,6 +65,7 @@
#include <xen/balloon.h>
#include <xen/features.h>
#include <xen/page.h>
+#include <xen/xenbus.h>

/*
* balloon_process() state:
@@ -586,6 +587,9 @@ static void __init balloon_add_region(unsigned long start_pfn,
static int __init balloon_init(void)
{
int i;
+#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
+ int rc;
+#endif

if (!xen_domain())
return -ENODEV;
@@ -621,6 +625,27 @@ static int __init balloon_init(void)
balloon_add_region(PFN_UP(xen_extra_mem[i].start),
PFN_DOWN(xen_extra_mem[i].size));

+#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
+ /*
+ * Notify a host about our memory size limit.
+ *
+ * The guest-max value is in KiB, so MAX_DOMAIN_PAGES should
+ * be converted respectively. PAGE_SHIFT converts pages to bytes,
+ * hence PAGE_SHIFT - 10.
+ */
+ rc = xenbus_printf(XBT_NIL, "memory", "guest-max", "%lu",
+ MAX_DOMAIN_PAGES << (PAGE_SHIFT - 10));
+
+ if (rc < 0)
+ pr_info("xen/balloon: Memory hotplug may not be supported "
+ "in some environments: %i\n", rc);
+#else
+ xenbus_printf(XBT_NIL, "memory", "guest-max", "%lu",
+ (balloon_stats.current_pages +
+ balloon_stats.balloon_low +
+ balloon_stats.balloon_high) << (PAGE_SHIFT - 10));
+#endif
+
return 0;
}

--
1.7.10.4


\
 
 \ /
  Last update: 2013-04-29 14:01    [W:0.066 / U:0.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site