ia64/xen-unstable

changeset 2403:b079795700ab

bitkeeper revision 1.1159.1.118 (41370c33N7_5pjKepga6V4ZmyTSNnQ)

Add support for maxmem in xm create and config.
author mjw@wray-m-3.hpl.hp.com
date Thu Sep 02 12:04:03 2004 +0000 (2004-09-02)
parents d61d24fa60a4
children 9dfa683873c2
files docs/xen_config.html tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/docs/xen_config.html	Thu Sep 02 11:15:48 2004 +0000
     1.2 +++ b/docs/xen_config.html	Thu Sep 02 12:04:03 2004 +0000
     1.3 @@ -60,6 +60,7 @@ The top-level element, a virtual machine
     1.4      <li>name: string, required. Domain name.
     1.5      <li>id: int, optional, default generated. Domain unique id.
     1.6      <li>memory: int, required. Domain memory in MB.
     1.7 +    <li>maxmem: int, optional. Maximum domain memory in MB.
     1.8      <li>cpu: int, optional. Cpu to run on.
     1.9      <li>cpu_weight, float, optional, default 1. Cpu weight - controls share of CPU.
    1.10      <li>image: linux | netbsd | ..., required. Domain image (OS-specific element).
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Sep 02 11:15:48 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Sep 02 12:04:03 2004 +0000
     2.3 @@ -831,6 +831,14 @@ class XendDomainInfo:
     2.4              self.config.remove(['device', dev_config])
     2.5          dev.destroy()
     2.6  
     2.7 +    def configure_memory(self):
     2.8 +        """Configure vm memory limit.
     2.9 +        """
    2.10 +        maxmem = sxp.get_child_value(self.config, "maxmem")
    2.11 +        if maxmem is None:
    2.12 +            maxmem = self.memory
    2.13 +        xc.domain_setmaxmem(self.dom, maxmem_kb = maxmem * 1024)
    2.14 +
    2.15      def configure_console(self):
    2.16          """Configure the vm console port.
    2.17          """
    2.18 @@ -1140,11 +1148,28 @@ def vm_field_ignore(vm, config, val, ind
    2.19  
    2.20      @param vm:        virtual machine
    2.21      @param config:    vm config
    2.22 -    @param val:       vfr field
    2.23 +    @param val:       config field
    2.24      @param index:     field index
    2.25      """
    2.26      pass
    2.27  
    2.28 +def vm_field_maxmem(vm, config, val, index):
    2.29 +    """Configure vm memory limit.
    2.30 +
    2.31 +    @param vm:        virtual machine
    2.32 +    @param config:    vm config
    2.33 +    @param val:       config field
    2.34 +    @param index:     field index
    2.35 +    """
    2.36 +    maxmem = sxp.child0(val)
    2.37 +    if maxmem is None:
    2.38 +        maxmem = vm.memory
    2.39 +    try:
    2.40 +        maxmem = int(maxmem)
    2.41 +    except:
    2.42 +        raise VmError("invalid maxmem: " + str(maxmem))
    2.43 +    xc.domain_setmaxmem(vm.dom, maxmem_kb = maxmem * 1024)
    2.44 +
    2.45  # Register image handlers.
    2.46  add_image_handler('linux',  vm_image_linux)
    2.47  add_image_handler('netbsd', vm_image_netbsd)
    2.48 @@ -1165,3 +1190,4 @@ add_config_handler('device',     vm_fiel
    2.49  add_config_handler('backend',    vm_field_ignore)
    2.50  
    2.51  # Register other config handlers.
    2.52 +add_config_handler('maxmem',     vm_field_maxmem)
     3.1 --- a/tools/python/xen/xm/create.py	Thu Sep 02 11:15:48 2004 +0000
     3.2 +++ b/tools/python/xen/xm/create.py	Thu Sep 02 12:04:03 2004 +0000
     3.3 @@ -99,6 +99,10 @@ gopts.var('memory', val='MEMORY',
     3.4            fn=set_int, default=128,
     3.5            use="Domain memory in MB.")
     3.6  
     3.7 +gopts.var('maxmem', val='MEMORY',
     3.8 +          fn=set_int, default=None,
     3.9 +          use="Maximum domain memory in MB.")
    3.10 +
    3.11  gopts.var('cpu', val='CPU',
    3.12            fn=set_int, default=None,
    3.13            use="CPU to run the domain on.")
    3.14 @@ -310,6 +314,8 @@ def make_config(vals):
    3.15      config = ['vm',
    3.16                ['name', vals.name ],
    3.17                ['memory', vals.memory ]]
    3.18 +    if vals.maxmem:
    3.19 +        config.append(['maxmem', vals.maxmem])
    3.20      if vals.cpu is not None:
    3.21          config.append(['cpu', vals.cpu])
    3.22      if vals.cpu_weight is not None: