WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] PoD memory 9/9: xend integration

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] PoD memory 9/9: xend integration
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 08 Jan 2009 06:57:27 -0800
Delivery-date: Thu, 08 Jan 2009 07:00:39 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1231152423 0
# Node ID 5b44cfde9666e3262e553ec2ad3ddb48fee23f50
# Parent  2a8ae362a82844090b698eebfce32068bb5093a7
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@xxxxxxxxxxxxx>
---
 tools/python/xen/lowlevel/xc/xc.c       |   45 ++++++++++++++++++++++++++------
 tools/python/xen/xend/XendDomainInfo.py |    6 +++-
 tools/python/xen/xend/image.py          |    7 +++-
 3 files changed, 47 insertions(+), 11 deletions(-)

diff -r 2a8ae362a828 -r 5b44cfde9666 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Mon Jan 05 10:46:37 2009 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Mon Jan 05 10:47:03 2009 +0000
@@ -890,17 +890,20 @@ static PyObject *pyxc_hvm_build(XcObject
     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) )
-        return NULL;
-
-    if ( xc_hvm_build(self->xc_handle, dom, memsize, image) != 0 )
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list,
+                                      &dom, &memsize, &image, &target, &vcpus,
+                                      &acpi, &apic) )
+        return NULL;
+
+    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 @@ static PyObject *pyxc_domain_setmaxmem(X
         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);
@@ -1813,6 +1834,14 @@ static PyMethodDef pyxc_methods[] = {
       "Set a domain's memory limit\n"
       " dom [int]: Identifier of domain.\n"
       " 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", 
diff -r 2a8ae362a828 -r 5b44cfde9666 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Mon Jan 05 10:46:37 2009 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Mon Jan 05 10:47:03 2009 +0000
@@ -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 -r 2a8ae362a828 -r 5b44cfde9666 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Mon Jan 05 10:46:37 2009 +0000
+++ b/tools/python/xen/xend/image.py    Mon Jan 05 10:47:03 2009 +0000
@@ -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)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] PoD memory 9/9: xend integration, Xen patchbot-unstable <=