mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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>
This commit is contained in:
1 parent
f5fec95647
commit
5bbed21d17
3 files changed
+45
-9
No files matched your search
@@ -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"
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||