ia64/xen-unstable

changeset 14539:f434c63b484a

Add VM.set_memory_dynamic_*_live methods, and use those in xm mem-set.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Ewan Mellor <ewan@xensource.com>
date Fri Mar 23 17:14:22 2007 +0000 (2007-03-23)
parents 2249cb6b5e42
children 238ed1c75194
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Fri Mar 23 16:54:34 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Fri Mar 23 17:14:22 2007 +0000
     1.3 @@ -1053,8 +1053,6 @@ class XendAPI(object):
     1.4  
     1.5      VM_attr_ro = ['power_state',
     1.6                    'resident_on',
     1.7 -                  'memory_static_max',
     1.8 -                  'memory_static_min',
     1.9                    'consoles',
    1.10                    'VIFs',
    1.11                    'VBDs',
    1.12 @@ -1072,6 +1070,8 @@ class XendAPI(object):
    1.13                    'auto_power_on',
    1.14                    'memory_dynamic_max',
    1.15                    'memory_dynamic_min',
    1.16 +                  'memory_static_max',
    1.17 +                  'memory_static_min',
    1.18                    'VCPUs_max',
    1.19                    'VCPUs_at_startup',
    1.20                    'VCPUs_params',
    1.21 @@ -1112,6 +1112,8 @@ class XendAPI(object):
    1.22                    ('add_to_other_config', None),
    1.23                    ('remove_from_other_config', None),
    1.24                    ('save', None),
    1.25 +                  ('set_memory_dynamic_max_live', None),
    1.26 +                  ('set_memory_dynamic_min_live', None),
    1.27                    ('send_trigger', None)]
    1.28      
    1.29      VM_funcs  = [('create', 'VM'),
    1.30 @@ -1315,12 +1317,38 @@ class XendAPI(object):
    1.31      
    1.32      def VM_set_memory_dynamic_max(self, session, vm_ref, mem):
    1.33          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    1.34 -        return xen_api_todo()
    1.35 -    
    1.36 +        dom.set_memory_dynamic_max(int(mem))
    1.37 +        return xen_api_success_void()
    1.38 +
    1.39      def VM_set_memory_dynamic_min(self, session, vm_ref, mem):
    1.40          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    1.41 -        return xen_api_todo()
    1.42 +        dom.set_memory_dynamic_min(int(mem))
    1.43 +        return xen_api_success_void()
    1.44 +
    1.45 +    def VM_set_memory_static_max(self, session, vm_ref, mem):
    1.46 +        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    1.47 +        dom.set_memory_static_max(int(mem))
    1.48 +        return xen_api_success_void()
    1.49      
    1.50 +    def VM_set_memory_static_min(self, session, vm_ref, mem):
    1.51 +        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    1.52 +        dom.set_memory_static_min(int(mem))
    1.53 +        return xen_api_success_void()
    1.54 +
    1.55 +    def VM_set_memory_dynamic_max_live(self, session, vm_ref, mem):
    1.56 +        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    1.57 +        dom.set_memory_dynamic_max(int(mem))
    1.58 +        # need to pass target as MiB
    1.59 +        dom.setMemoryTarget(int(mem)/1024/1024)
    1.60 +        return xen_api_success_void()
    1.61 +
    1.62 +    def VM_set_memory_dynamic_min_live(self, session, vm_ref, mem):
    1.63 +        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
    1.64 +        dom.set_memory_dynamic_min(int(mem))
    1.65 +        # need to pass target as MiB
    1.66 +        dom.setMemoryTarget(int(mem)/1024/1024)
    1.67 +        return xen_api_success_void()
    1.68 +
    1.69      def VM_set_VCPUs_params(self, session, vm_ref, value):
    1.70          return self.VM_set('vcpus_params', session, vm_ref, value)
    1.71  
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Mar 23 16:54:34 2007 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Mar 23 17:14:22 2007 +0000
     2.3 @@ -2078,6 +2078,16 @@ class XendDomainInfo:
     2.4          return self.info.get('memory_dynamic_max', 0)
     2.5      def get_memory_dynamic_min(self):
     2.6          return self.info.get('memory_dynamic_min', 0)
     2.7 +
     2.8 +    def set_memory_static_max(self, val):
     2.9 +        self.info['memory_static_max'] = val
    2.10 +    def set_memory_static_min(self, val):
    2.11 +        self.info['memory_static_min'] = val
    2.12 +    def set_memory_dynamic_max(self, val):
    2.13 +        self.info['memory_dynamic_max'] = val
    2.14 +    def set_memory_dynamic_min(self, val):
    2.15 +        self.info['memory_dynamic_min'] = val
    2.16 +    
    2.17      def get_vcpus_params(self):
    2.18          if self.getDomid() is None:
    2.19              return self.info['vcpus_params']
     3.1 --- a/tools/python/xen/xm/main.py	Fri Mar 23 16:54:34 2007 +0000
     3.2 +++ b/tools/python/xen/xm/main.py	Fri Mar 23 17:14:22 2007 +0000
     3.3 @@ -1281,8 +1281,10 @@ def xm_mem_set(args):
     3.4  
     3.5      if serverType == SERVER_XEN_API:
     3.6          mem_target = int_unit(args[1], 'm') * 1024 * 1024
     3.7 -        server.xenapi.VM.set_memory_dynamic_max(get_single_vm(dom), mem_target)
     3.8 -        server.xenapi.VM.set_memory_dynamic_min(get_single_vm(dom), mem_target)
     3.9 +        server.xenapi.VM.set_memory_dynamic_max_live(get_single_vm(dom),
    3.10 +                                                     mem_target)
    3.11 +        server.xenapi.VM.set_memory_dynamic_min_live(get_single_vm(dom),
    3.12 +                                                     mem_target)
    3.13      else:
    3.14          mem_target = int_unit(args[1], 'm')
    3.15          server.xend.domain.setMemoryTarget(dom, mem_target)