[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC][PATCH] 9/9 Populate-on-demand memory: 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@xxxxxxxxxxxxx> diff -r a6133df55f3f tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Fri Dec 19 17:54:46 2008 +0000 +++ b/tools/python/xen/lowlevel/xc/xc.c Fri Dec 19 17:55:08 2008 +0000 @@ -890,17 +890,20 @@ 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__) @@ -1329,6 +1332,24 @@ return NULL; if (xc_domain_setmaxmem(self->xc_handle, dom, maxmem_kb) != 0) + return pyxc_error_to_exception(); + + Py_INCREF(zero); + 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); @@ -1815,6 +1836,14 @@ " 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 -r a6133df55f3f tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Fri Dec 19 17:54:46 2008 +0000 +++ b/tools/python/xen/xend/XendDomainInfo.py Fri Dec 19 17:55:08 2008 +0000 @@ -1104,10 +1104,10 @@ 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 @@ 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 -r a6133df55f3f tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.py Fri Dec 19 17:54:46 2008 +0000 +++ b/tools/python/xen/xend/image.py Fri Dec 19 17:55:08 2008 +0000 @@ -799,19 +799,22 @@ 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) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |