ia64/xen-unstable

changeset 2673:081dd58e4d58

bitkeeper revision 1.1159.1.247 (41770cc6Kk3qrDm03nejgR15F8G8Ng)

Full balloon driver support for 2.6, including control interface
and plumbing into xend / xm.
author mwilli2@equilibrium.research
date Thu Oct 21 01:11:34 2004 +0000 (2004-10-21)
parents 0c8e3e76fd4f
children 1c21b245b050
files linux-2.6.8.1-xen-sparse/drivers/xen/balloon/balloon.c tools/python/xen/lowlevel/xu/xu.c tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/domain.py tools/python/xen/xend/server/messages.py tools/python/xen/xm/main.py xen/include/hypervisor-ifs/io/domain_controller.h
line diff
     1.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/balloon/balloon.c	Wed Oct 20 16:20:01 2004 +0000
     1.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/balloon/balloon.c	Thu Oct 21 01:11:34 2004 +0000
     1.3 @@ -521,7 +521,7 @@ static int __init balloon_init(void)
     1.4  {
     1.5      printk(KERN_ALERT "Starting Xen Balloon driver\n");
     1.6  
     1.7 -    most_seen_pages = current_pages = min(start_info.nr_pages,max_pfn);
     1.8 +    most_seen_pages = current_pages = min(xen_start_info.nr_pages,max_pfn);
     1.9      if ( (balloon_pde = create_xen_proc_entry("memory_target", 0644)) == NULL )
    1.10      {
    1.11          printk(KERN_ALERT "Unable to create balloon driver proc entry!");
    1.12 @@ -538,14 +538,14 @@ static int __init balloon_init(void)
    1.13      /* 
    1.14       * make_module a new phys map if mem= says xen can give us memory  to grow
    1.15       */
    1.16 -    if ( max_pfn > start_info.nr_pages )
    1.17 +    if ( max_pfn > xen_start_info.nr_pages )
    1.18      {
    1.19          extern unsigned long *phys_to_machine_mapping;
    1.20          unsigned long *newmap;
    1.21          newmap = (unsigned long *)vmalloc(max_pfn * sizeof(unsigned long));
    1.22          memset(newmap, ~0, max_pfn * sizeof(unsigned long));
    1.23          memcpy(newmap, phys_to_machine_mapping,
    1.24 -               start_info.nr_pages * sizeof(unsigned long));
    1.25 +               xen_start_info.nr_pages * sizeof(unsigned long));
    1.26          phys_to_machine_mapping = newmap;
    1.27      }
    1.28  
     2.1 --- a/tools/python/xen/lowlevel/xu/xu.c	Wed Oct 20 16:20:01 2004 +0000
     2.2 +++ b/tools/python/xen/lowlevel/xu/xu.c	Thu Oct 21 01:11:34 2004 +0000
     2.3 @@ -479,6 +479,10 @@ static PyObject *xu_message_get_payload(
     2.4      case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DRIVER_STATUS):
     2.5          C2P(netif_be_driver_status_t, status, Int, Long);
     2.6          return dict;
     2.7 +    case TYPE(CMSG_MEM_REQUEST, CMSG_MEM_REQUEST_SET):
     2.8 +        C2P(mem_request_t, target, Int, Long);
     2.9 +        C2P(mem_request_t, status, Int, Long);
    2.10 +        return dict;
    2.11      }
    2.12  
    2.13      return PyString_FromStringAndSize(xum->msg.msg, xum->msg.length);
    2.14 @@ -640,6 +644,10 @@ static PyObject *xu_message_new(PyObject
    2.15          P2C(netif_fe_driver_status_t, status,        u32);
    2.16          P2C(netif_fe_driver_status_t, max_handle,    u32);
    2.17          break;
    2.18 +    case TYPE(CMSG_MEM_REQUEST, CMSG_MEM_REQUEST_SET):
    2.19 +        P2C(mem_request_t, target, u32);
    2.20 +        P2C(mem_request_t, status, u32);
    2.21 +        break;
    2.22      }
    2.23  
    2.24      if ( dict_items_parsed != PyDict_Size(payload) )
     3.1 --- a/tools/python/xen/xend/XendClient.py	Wed Oct 20 16:20:01 2004 +0000
     3.2 +++ b/tools/python/xen/xend/XendClient.py	Thu Oct 21 01:11:34 2004 +0000
     3.3 @@ -350,6 +350,12 @@ class Xend:
     3.4                               {'op'      : 'inject',
     3.5                                'event'   : fileof(sxpr) })
     3.6  
     3.7 +    def xend_domain_mem_target_set(self, id, mem_target):
     3.8 +        val = self.xendPost(self.domainurl(id),
     3.9 +                            {'op'         : 'mem_target_set',
    3.10 +                             'target'     : mem_target })
    3.11 +        return val
    3.12 +
    3.13  def getAsynchXendClientProtocol():
    3.14      """Load AsynchXendClientProtocol on demand to avoid the cost.
    3.15      """
     4.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Oct 20 16:20:01 2004 +0000
     4.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Oct 21 01:11:34 2004 +0000
     4.3 @@ -811,6 +811,10 @@ class XendDomain:
     4.4          except Exception, ex:
     4.5              raise XendError(str(ex))
     4.6  
     4.7 +    def domain_mem_target_set(self, id, target):
     4.8 +        return xend.domain_mem_target_set(id, target)
     4.9 +        
    4.10 +
    4.11  
    4.12  def instance():
    4.13      """Singleton constructor. Use this instead of the class constructor.
     5.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Wed Oct 20 16:20:01 2004 +0000
     5.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Thu Oct 21 01:11:34 2004 +0000
     5.3 @@ -706,6 +706,16 @@ class Daemon:
     5.4              raise XendError('No domain controller: %s' % dom)
     5.5          ctrl.shutdown(reason)
     5.6          return 0
     5.7 +
     5.8 +    def domain_mem_target_set(self, dom, target):
     5.9 +        """Set memory target for a domain.
    5.10 +        """
    5.11 +        dom = int(dom)
    5.12 +        ctrl = self.domainCF.getController(dom)
    5.13 +        if not ctrl:
    5.14 +            raise XendError('No domain controller: %s' % dom)
    5.15 +        ctrl.mem_target_set(target)
    5.16 +        return 0
    5.17          
    5.18  def instance():
    5.19      global inst
     6.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Wed Oct 20 16:20:01 2004 +0000
     6.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Thu Oct 21 01:11:34 2004 +0000
     6.3 @@ -194,12 +194,19 @@ class SrvDomain(SrvDir):
     6.4          val = fn(req.args, {'dom': self.dom.id})
     6.5          return val
     6.6  
     6.7 +    def op_mem_target_set(self, op, req):
     6.8 +        fn = FormFn(self.xd.domain_mem_target_set,
     6.9 +                    [['dom', 'str'],
    6.10 +                     ['target', 'int']])
    6.11 +        val = fn(req.args, {'dom': self.dom.id})
    6.12 +        return val
    6.13 +
    6.14      def render_POST(self, req):
    6.15          return self.perform(req)
    6.16          
    6.17      def render_GET(self, req):
    6.18          op = req.args.get('op')
    6.19 -        if op and op[0] in ['vifs', 'vif', 'vbds', 'vbd']:
    6.20 +        if op and op[0] in ['vifs', 'vif', 'vbds', 'vbd', 'mem_target_set']:
    6.21              return self.perform(req)
    6.22          if self.use_sxp(req):
    6.23              req.setHeader("Content-Type", sxp.mime_type)
     7.1 --- a/tools/python/xen/xend/server/domain.py	Wed Oct 20 16:20:01 2004 +0000
     7.2 +++ b/tools/python/xen/xend/server/domain.py	Thu Oct 21 01:11:34 2004 +0000
     7.3 @@ -33,6 +33,7 @@ class DomainController(controller.Contro
     7.4      def __init__(self, factory, dom):
     7.5          controller.Controller.__init__(self, factory, dom)
     7.6          self.addMethod(CMSG_SHUTDOWN, 0, None)
     7.7 +        self.addMethod(CMSG_MEM_REQUEST, 0, None)
     7.8          self.registerChannel()
     7.9  
    7.10      def shutdown(self, reason):
    7.11 @@ -45,3 +46,9 @@ class DomainController(controller.Contro
    7.12              raise XendError('invalid reason:' + reason)
    7.13          msg = packMsg(msgtype, {})
    7.14          self.writeRequest(msg)
    7.15 +
    7.16 +    def mem_target_set(self, target):
    7.17 +        """Set domain memory target in pages.
    7.18 +        """
    7.19 +        msg = packMsg('mem_request_t', { 'target' : target * (1 << 8)} )
    7.20 +        self.writeRequest(msg)
     8.1 --- a/tools/python/xen/xend/server/messages.py	Wed Oct 20 16:20:01 2004 +0000
     8.2 +++ b/tools/python/xen/xend/server/messages.py	Thu Oct 21 01:11:34 2004 +0000
     8.3 @@ -216,7 +216,20 @@ shutdown_formats = {
     8.4  msg_formats.update(shutdown_formats)
     8.5  
     8.6  #============================================================================
     8.7 +# Domain memory reservation message.
     8.8 +#============================================================================
     8.9  
    8.10 +CMSG_MEM_REQUEST = 7
    8.11 +CMSG_MEM_REQUEST_SET = 0
    8.12 +
    8.13 +mem_request_formats = {
    8.14 +    'mem_request_t':
    8.15 +    (CMSG_MEM_REQUEST, CMSG_MEM_REQUEST_SET)
    8.16 +    }
    8.17 +
    8.18 +msg_formats.update(mem_request_formats)
    8.19 +
    8.20 +#============================================================================
    8.21  class Msg:
    8.22      pass
    8.23  
     9.1 --- a/tools/python/xen/xm/main.py	Wed Oct 20 16:20:01 2004 +0000
     9.2 +++ b/tools/python/xen/xm/main.py	Thu Oct 21 01:11:34 2004 +0000
     9.3 @@ -466,6 +466,24 @@ class ProgMaxmem(Prog):
     9.4  
     9.5  xm.prog(ProgMaxmem)
     9.6  
     9.7 +class ProgBalloon(Prog):
     9.8 +    group = 'domain'
     9.9 +    name  = 'balloon'
    9.10 +    info  = """Set the domain's memory footprint using the balloon driver."""
    9.11 +
    9.12 +    def help(self, args):
    9.13 +        print args[0], "DOM MEMORY_TARGET"
    9.14 +        print """\nRequest domain DOM to adjust its memory footprint to
    9.15 +MEMORY_TARGET megabytes"""
    9.16 +
    9.17 +    def main(self, args):
    9.18 +        if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
    9.19 +        dom = args[1]
    9.20 +        mem_target = int(args[2])
    9.21 +        server.xend_domain_mem_target_set(dom, mem_target)
    9.22 +
    9.23 +xm.prog(ProgBalloon)
    9.24 +
    9.25  class ProgDomid(Prog):
    9.26      group = 'domain'
    9.27      name = 'domid'
    10.1 --- a/xen/include/hypervisor-ifs/io/domain_controller.h	Wed Oct 20 16:20:01 2004 +0000
    10.2 +++ b/xen/include/hypervisor-ifs/io/domain_controller.h	Thu Oct 21 01:11:34 2004 +0000
    10.3 @@ -53,6 +53,7 @@ typedef struct {
    10.4  #define CMSG_NETIF_BE       3  /* Network-device backend  */
    10.5  #define CMSG_NETIF_FE       4  /* Network-device frontend */
    10.6  #define CMSG_SHUTDOWN       6  /* Shutdown messages       */
    10.7 +#define CMSG_MEM_REQUEST    7  /* Memory reservation reqs */
    10.8  
    10.9  
   10.10  /******************************************************************************
   10.11 @@ -555,4 +556,23 @@ typedef struct {
   10.12  #define CMSG_SHUTDOWN_SUSPEND   2   /* Create suspend info, then             */
   10.13                                      /* SHUTDOWN_suspend.                     */
   10.14  
   10.15 +
   10.16 +/******************************************************************************
   10.17 + * MEMORY CONTROLS
   10.18 + */
   10.19 +
   10.20 +#define CMSG_MEM_REQUEST_SET 0 /* Request a domain to set its mem footprint. */
   10.21 +
   10.22 +/*
   10.23 + * CMSG_MEM_REQUEST:
   10.24 + *  Request that the domain change its memory reservation.
   10.25 + */
   10.26 +typedef struct {
   10.27 +    /* OUT */
   10.28 +    u32 target;       /* 0: Target memory reservation in pages.       */
   10.29 +    /* IN  */
   10.30 +    u32 status;       /* 4: Return code indicates success or failure. */
   10.31 +} PACKED mem_request_t; /* 8 bytes */
   10.32 +
   10.33 +
   10.34  #endif /* __DOMAIN_CONTROLLER_H__ */