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] Fix mem-set, mem-max, and vcpu-set comman

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Fix mem-set, mem-max, and vcpu-set commands when used against inactive domains.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Dec 2006 15:40:34 +0000
Delivery-date: Fri, 15 Dec 2006 07:40:07 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID bc3ff220d24d083f8ff170969cc4eeed5fdb428f
# Parent  779e99f810ca5239b8565db1ecd420f4d40a3bb0
Fix mem-set, mem-max, and vcpu-set commands when used against inactive domains.

Signed-off-by: Daniel P. Berrange  <berrange@xxxxxxxxxx>
---
 tools/python/xen/xend/XendDomain.py       |    6 ---
 tools/python/xen/xend/XendDomainInfo.py   |   57 +++++++++++++++++++++++-------
 tools/python/xen/xend/server/SrvDomain.py |    9 +---
 3 files changed, 48 insertions(+), 24 deletions(-)

diff -r 779e99f810ca -r bc3ff220d24d tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Fri Dec 15 11:48:40 2006 +0000
+++ b/tools/python/xen/xend/XendDomain.py       Fri Dec 15 11:50:04 2006 +0000
@@ -1339,11 +1339,7 @@ class XendDomain:
         dominfo = self.domain_lookup_nr(domid)
         if not dominfo:
             raise XendInvalidDomain(str(domid))
-        maxmem = int(mem) * 1024
-        try:
-            return xc.domain_setmaxmem(dominfo.getDomid(), maxmem)
-        except Exception, ex:
-            raise XendError(str(ex))
+        dominfo.setMemoryMaximum(mem)
 
     def domain_ioport_range_enable(self, domid, first, last):
         """Enable access to a range of IO ports for a domain
diff -r 779e99f810ca -r bc3ff220d24d tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Fri Dec 15 11:48:40 2006 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Fri Dec 15 11:50:04 2006 +0000
@@ -551,8 +551,34 @@ class XendDomainInfo:
             raise XendError('Invalid memory size')
         
         self.info['memory_static_min'] = target
-        self.storeVm("memory", target)
-        self.storeDom("memory/target", target << 10)
+        if self.domid >= 0:
+            self.storeVm("memory", target)
+            self.storeDom("memory/target", target << 10)
+        else:
+            self.info['memory_dynamic_min'] = target
+            xen.xend.XendDomain.instance().managed_config_save(self)
+
+    def setMemoryMaximum(self, limit):
+        """Set the maximum memory limit of this domain
+        @param limit: In MiB.
+        """
+        log.debug("Setting memory maximum of domain %s (%d) to %d MiB.",
+                  self.info['name_label'], self.domid, limit)
+
+        if limit <= 0:
+            raise XendError('Invalid memory size')
+
+        self.info['memory_static_max'] = limit
+        if self.domid >= 0:
+            maxmem = int(limit) * 1024
+            try:
+                return xc.domain_setmaxmem(self.domid, maxmem)
+            except Exception, ex:
+                raise XendError(str(ex))
+        else:
+            self.info['memory_dynamic_max'] = limit
+            xen.xend.XendDomain.instance().managed_config_save(self)
+
 
     def getVCPUInfo(self):
         try:
@@ -831,18 +857,23 @@ class XendDomainInfo:
 
     def setVCpuCount(self, vcpus):
         self.info['vcpu_avail'] = (1 << vcpus) - 1
-        self.storeVm('vcpu_avail', self.info['vcpu_avail'])
-        # update dom differently depending on whether we are adjusting
-        # vcpu number up or down, otherwise _vcpuDomDetails does not
-        # disable the vcpus
-        if self.info['vcpus_number'] > vcpus:
-            # decreasing
-            self._writeDom(self._vcpuDomDetails())
+        if self.domid >= 0:
+            self.storeVm('vcpu_avail', self.info['vcpu_avail'])
+            # update dom differently depending on whether we are adjusting
+            # vcpu number up or down, otherwise _vcpuDomDetails does not
+            # disable the vcpus
+            if self.info['vcpus_number'] > vcpus:
+                # decreasing
+                self._writeDom(self._vcpuDomDetails())
+                self.info['vcpus_number'] = vcpus
+            else:
+                # same or increasing
+                self.info['vcpus_number'] = vcpus
+                self._writeDom(self._vcpuDomDetails())
+        else:
             self.info['vcpus_number'] = vcpus
-        else:
-            # same or increasing
-            self.info['vcpus_number'] = vcpus
-            self._writeDom(self._vcpuDomDetails())
+            self.info['online_vcpus'] = vcpus
+            xen.xend.XendDomain.instance().managed_config_save(self)
 
     def getLabel(self):
         return security.get_security_info(self.info, 'label')
diff -r 779e99f810ca -r bc3ff220d24d tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Fri Dec 15 11:48:40 2006 +0000
+++ b/tools/python/xen/xend/server/SrvDomain.py Fri Dec 15 11:50:04 2006 +0000
@@ -160,12 +160,9 @@ class SrvDomain(SrvDir):
         return val
 
     def op_maxmem_set(self, _, req):
-        fn = FormFn(self.xd.domain_maxmem_set,
-                    [['dom',    'int'],
-                     ['memory', 'int']])
-        val = fn(req.args, {'dom': self.dom.domid})
-        return val
-
+        return self.call(self.dom.setMemoryMaximum,
+                         [['memory', 'int']],
+                         req)
     
     def call(self, fn, args, req):
         return FormFn(fn, args)(req.args)

_______________________________________________
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] Fix mem-set, mem-max, and vcpu-set commands when used against inactive domains., Xen patchbot-unstable <=