mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
This patch does 2 jobs:
- Enforce the number of CPUs dom0 will take. See the new variable "dom0-cpus" in xend-config.sxp (you will want to set this variable to 1 on SMP systems) - Balloon out dom0 memory when creating domU, if there is not enough free memory. The lowest level we will balloon out is configured via the new variable "dom0-min-mem" in xend-config.sxp I still have a doubt: where to put the code to enforce dom0-cpus. At the moment I put it into python/xen/xend/server/SrvDaemon.py, and hopefully that is resonable enough. Any comment? Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
This commit is contained in:
1 parent
613f9362cf
commit
084dedfee3
4 files changed
+85
-1
No files matched your search
@@ -76,6 +76,10 @@ class XendRoot:
|
||||
"""Default port xend serves consoles at. """
|
||||
console_port_base_default = '9600'
|
||||
|
||||
dom0_min_mem_default = '0'
|
||||
|
||||
dom0_cpus_default = '0'
|
||||
|
||||
components = {}
|
||||
|
||||
def __init__(self):
|
||||
@@ -329,6 +333,12 @@ class XendRoot:
|
||||
def get_vif_antispoof(self):
|
||||
return self.get_config_bool('vif-antispoof', 'yes')
|
||||
|
||||
def get_dom0_min_mem(self):
|
||||
return self.get_config_int('dom0-min-mem', self.dom0_min_mem_default)
|
||||
|
||||
def get_dom0_cpus(self):
|
||||
return self.get_config_int('dom0-cpus', self.dom0_cpus_default)
|
||||
|
||||
def instance():
|
||||
"""Get an instance of XendRoot.
|
||||
Use this instead of the constructor.
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
###########################################################
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
@@ -16,6 +15,7 @@ import re
|
||||
import StringIO
|
||||
import traceback
|
||||
import time
|
||||
import glob
|
||||
|
||||
from xen.lowlevel import xu
|
||||
|
||||
@@ -25,6 +25,7 @@ from xen.xend import EventServer; eserver = EventServer.instance()
|
||||
from xen.xend.XendError import XendError
|
||||
from xen.xend.server import SrvServer
|
||||
from xen.xend.XendLogging import log
|
||||
from xen.xend import XendRoot; xroot = XendRoot.instance()
|
||||
|
||||
import channel
|
||||
import controller
|
||||
@@ -327,6 +328,7 @@ class Daemon:
|
||||
return self.cleanup(kill=True)
|
||||
|
||||
def run(self):
|
||||
_enforce_dom0_cpus()
|
||||
try:
|
||||
log.info("Xend Daemon started")
|
||||
self.createFactories()
|
||||
@@ -363,6 +365,32 @@ class Daemon:
|
||||
#sys.exit(rc)
|
||||
os._exit(rc)
|
||||
|
||||
def _enforce_dom0_cpus():
|
||||
dn = xroot.get_dom0_cpus()
|
||||
|
||||
for d in glob.glob("/sys/devices/system/cpu/cpu*"):
|
||||
cpu = int(os.path.basename(d)[3:])
|
||||
if (dn == 0) or (cpu < dn):
|
||||
v = "1"
|
||||
else:
|
||||
v = "0"
|
||||
try:
|
||||
f = open("%s/online" %d, "r+")
|
||||
c = f.read(1)
|
||||
if (c != v):
|
||||
if v == "0":
|
||||
log.info("dom0 is trying to give back cpu %d", cpu)
|
||||
else:
|
||||
log.info("dom0 is trying to take cpu %d", cpu)
|
||||
f.seek(0)
|
||||
f.write(v)
|
||||
f.close()
|
||||
log.info("dom0 successfully enforced cpu %d", cpu)
|
||||
else:
|
||||
f.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
def instance():
|
||||
global inst
|
||||
try:
|
||||
|
||||