ia64/xen-unstable

changeset 6916:8cba45a77249

Make dom0_enforce_cpus() use vcpu_hotplug rather than directly modifying the sysfs entries.
Directly modifying the sysfs entries causes the xenstore state of
a cpu's availability to be incorrect. Also slightly modify the
dom0-cpus description in the xend-config. Rather than specifying which
dom0 vcpus are to be used, it is now a target of how many vcpus to use
as pinvcpu ops are the preferred method for setting which physical cpu a
vcpu uses.
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Sep 16 19:08:36 2005 +0000 (2005-09-16)
parents a4cf3e17bb25
children 4490e39fc322
files tools/examples/xend-config.sxp tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvDaemon.py
line diff
     1.1 --- a/tools/examples/xend-config.sxp	Fri Sep 16 18:59:59 2005 +0000
     1.2 +++ b/tools/examples/xend-config.sxp	Fri Sep 16 19:08:36 2005 +0000
     1.3 @@ -49,6 +49,6 @@
     1.4  # If dom0-min-mem=0, dom0 will never balloon out.
     1.5  (dom0-min-mem 0)
     1.6  
     1.7 -# In SMP system, dom0 will use only CPUs in range [1,dom0-cpus]
     1.8 +# In SMP system, dom0 will use dom0-cpus # of CPUS
     1.9  # If dom0-cpus = 0, dom0 will take all cpus available
    1.10  (dom0-cpus 0)
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Sep 16 18:59:59 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Sep 16 19:08:36 2005 +0000
     2.3 @@ -155,6 +155,7 @@ class XendDomain:
     2.4          if not dom0:
     2.5              dom0 = self.domain_unknown(0)
     2.6          dom0.dom0_init_store()    
     2.7 +        dom0.dom0_enforce_cpus()
     2.8  
     2.9      def close(self):
    2.10          pass
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 16 18:59:59 2005 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 16 19:08:36 2005 +0000
     3.3 @@ -1120,6 +1120,26 @@ class XendDomainInfo:
     3.4              # get run-time value of vcpus and update store
     3.5              self.configure_vcpus(dom_get(self.domid)['vcpus'])
     3.6  
     3.7 +    def dom0_enforce_cpus(self):
     3.8 +        dom = 0
     3.9 +        # get max number of cpus to use for dom0 from config
    3.10 +        from xen.xend import XendRoot
    3.11 +        xroot = XendRoot.instance()
    3.12 +        target = int(xroot.get_dom0_cpus())
    3.13 +        log.debug("number of cpus to use is %d" % (target))
    3.14 +   
    3.15 +        # target = 0 means use all processors
    3.16 +        if target > 0:
    3.17 +            # count the number of online vcpus (cpu values in v2c map >= 0)
    3.18 +            vcpu_to_cpu = dom_get(dom)['vcpu_to_cpu']
    3.19 +            vcpus_online = len(filter(lambda x: x >= 0, vcpu_to_cpu))
    3.20 +            log.debug("found %d vcpus online" % (vcpus_online))
    3.21 +
    3.22 +            # disable any extra vcpus that are online over the requested target
    3.23 +            for vcpu in range(target, vcpus_online):
    3.24 +                log.info("enforcement is disabling DOM%d VCPU%d" % (dom, vcpu))
    3.25 +                self.vcpu_hotplug(vcpu, 0)
    3.26 +
    3.27  
    3.28  def vm_field_ignore(_, _1, _2, _3):
    3.29      """Dummy config field handler used for fields with built-in handling.
     4.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Fri Sep 16 18:59:59 2005 +0000
     4.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Fri Sep 16 19:08:36 2005 +0000
     4.3 @@ -298,7 +298,6 @@ class Daemon:
     4.4          return self.cleanup(kill=True)
     4.5  
     4.6      def run(self, status):
     4.7 -        _enforce_dom0_cpus()
     4.8          try:
     4.9              log.info("Xend Daemon started")
    4.10              event.listenEvent(self)
    4.11 @@ -323,32 +322,6 @@ class Daemon:
    4.12          #sys.exit(rc)
    4.13          os._exit(rc)
    4.14  
    4.15 -def _enforce_dom0_cpus():
    4.16 -    dn = xroot.get_dom0_cpus()
    4.17 -
    4.18 -    for d in glob.glob("/sys/devices/system/cpu/cpu*"):
    4.19 -        cpu = int(os.path.basename(d)[3:])
    4.20 -        if (dn == 0) or (cpu < dn):
    4.21 -            v = "1"
    4.22 -        else:
    4.23 -            v = "0"
    4.24 -        try:
    4.25 -            f = open("%s/online" %d, "r+")
    4.26 -            c = f.read(1)
    4.27 -            if (c != v):
    4.28 -                if v == "0":
    4.29 -                    log.info("dom0 is trying to give back cpu %d", cpu)
    4.30 -                else:
    4.31 -                    log.info("dom0 is trying to take cpu %d", cpu)
    4.32 -                f.seek(0)
    4.33 -                f.write(v)
    4.34 -                f.close()
    4.35 -                log.info("dom0 successfully enforced cpu %d", cpu)
    4.36 -            else:
    4.37 -                f.close()
    4.38 -        except:
    4.39 -            pass
    4.40 -
    4.41  def instance():
    4.42      global inst
    4.43      try: