aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-01-05 10:47:03 +0000
committerKeir Fraser <keir.fraser@citrix.com>2009-01-05 10:47:03 +0000
commit5bbed21d174342b7c3e413bdb3a3251cbe7679d1 (patch)
tree0e87ce35b69e768847a8541f8fcb376e7d72ee82 /tools
parentf5fec95647acc61536578537a1a1f6063b99b1cb (diff)
downloadxen-5bbed21d174342b7c3e413bdb3a3251cbe7679d1.tar.gz
xen-5bbed21d174342b7c3e413bdb3a3251cbe7679d1.tar.bz2
xen-5bbed21d174342b7c3e413bdb3a3251cbe7679d1.zip
PoD memory 9/9: xend integration
Xend integration for PoD functionality. * Add python bindings for xc_hvm_domain_build() and xc_domain_memory_set_pod_target() * Always call xc_hvm_domain_build(), with memsize = memory_static_max and target=memory_dynamic_max * When setting a new memory target: + First make sure we actually have enough free memory for the target setting to succeed + Call set_pod_target() with the new target, to Xen can do the Right Thing. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/lowlevel/xc/xc.c41
-rw-r--r--tools/python/xen/xend/XendDomainInfo.py6
-rw-r--r--tools/python/xen/xend/image.py7
3 files changed, 45 insertions, 9 deletions
diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index 29a81efdb3..9d549c66f6 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -890,17 +890,20 @@ static PyObject *pyxc_hvm_build(XcObject *self,
int i;
#endif
char *image;
- int memsize, vcpus = 1, acpi = 0, apic = 1;
+ int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1;
static char *kwd_list[] = { "domid",
- "memsize", "image", "vcpus", "acpi",
+ "memsize", "image", "target", "vcpus", "acpi",
"apic", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iii", kwd_list,
- &dom, &memsize,
- &image, &vcpus, &acpi, &apic) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list,
+ &dom, &memsize, &image, &target, &vcpus,
+ &acpi, &apic) )
return NULL;
- if ( xc_hvm_build(self->xc_handle, dom, memsize, image) != 0 )
+ if ( target == -1 )
+ target = memsize;
+
+ if ( xc_hvm_build_target_mem(self->xc_handle, dom, memsize, target, image) != 0 )
return pyxc_error_to_exception();
#if !defined(__ia64__)
@@ -1335,6 +1338,24 @@ static PyObject *pyxc_domain_setmaxmem(XcObject *self, PyObject *args)
return zero;
}
+static PyObject *pyxc_domain_set_target_mem(XcObject *self, PyObject *args)
+{
+ uint32_t dom;
+ unsigned int mem_kb, mem_pages;
+
+ if (!PyArg_ParseTuple(args, "ii", &dom, &mem_kb))
+ return NULL;
+
+ mem_pages = mem_kb / 4;
+
+ if (xc_domain_memory_set_pod_target(self->xc_handle, dom, mem_pages,
+ NULL, NULL, NULL) != 0)
+ return pyxc_error_to_exception();
+
+ Py_INCREF(zero);
+ return zero;
+}
+
static PyObject *pyxc_domain_set_memmap_limit(XcObject *self, PyObject *args)
{
uint32_t dom;
@@ -1815,6 +1836,14 @@ static PyMethodDef pyxc_methods[] = {
" maxmem_kb [int]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
+ { "domain_set_target_mem",
+ (PyCFunction)pyxc_domain_set_target_mem,
+ METH_VARARGS, "\n"
+ "Set a domain's memory target\n"
+ " dom [int]: Identifier of domain.\n"
+ " mem_kb [int]: .\n"
+ "Returns: [int] 0 on success; -1 on error.\n" },
+
{ "domain_set_memmap_limit",
(PyCFunction)pyxc_domain_set_memmap_limit,
METH_VARARGS, "\n"
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 424e08e65e..3cc054dba1 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -1104,10 +1104,10 @@ class XendDomainInfo:
self.info['name_label'], str(self.domid), target)
MiB = 1024 * 1024
+ memory_cur = self.get_memory_dynamic_max() / MiB
if self.domid == 0:
dom0_min_mem = xoptions.get_dom0_min_mem()
- memory_cur = self.get_memory_dynamic_max() / MiB
if target < memory_cur and dom0_min_mem > target:
raise XendError("memory_dynamic_max too small")
@@ -1115,8 +1115,12 @@ class XendDomainInfo:
self._safe_set_memory('memory_dynamic_max', target * MiB)
if self.domid >= 0:
+ if target > memory_cur:
+ balloon.free( (target-memory_cur)*1024 )
self.storeVm("memory", target)
self.storeDom("memory/target", target << 10)
+ xc.domain_set_target_mem(self.domid,
+ (target * 1024))
xen.xend.XendDomain.instance().managed_config_save(self)
def setMemoryMaximum(self, limit):
diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
index e101665a15..ce390570e3 100644
--- a/tools/python/xen/xend/image.py
+++ b/tools/python/xen/xend/image.py
@@ -799,19 +799,22 @@ class HVMImageHandler(ImageHandler):
def buildDomain(self):
store_evtchn = self.vm.getStorePort()
+ memmax_mb = self.getRequiredMaximumReservation() / 1024
mem_mb = self.getRequiredInitialReservation() / 1024
log.debug("domid = %d", self.vm.getDomid())
log.debug("image = %s", self.loader)
log.debug("store_evtchn = %d", store_evtchn)
- log.debug("memsize = %d", mem_mb)
+ log.debug("memsize = %d", memmax_mb)
+ log.debug("target = %d", mem_mb)
log.debug("vcpus = %d", self.vm.getVCpuCount())
log.debug("acpi = %d", self.acpi)
log.debug("apic = %d", self.apic)
rc = xc.hvm_build(domid = self.vm.getDomid(),
image = self.loader,
- memsize = mem_mb,
+ memsize = memmax_mb,
+ target = mem_mb,
vcpus = self.vm.getVCpuCount(),
acpi = self.acpi,
apic = self.apic)