mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.1159.6.5 (41179cd0aGJI1_zvJCg05dqagSOrlw)
Fix problem with wrong domain name in vifctl down. Add generic support to XendRoot to solve recursive mutual import problem.
This commit is contained in:
1 parent
693c7beb98
commit
9b9aa8ef37
4 files changed
+40
-6
No files matched your search
@@ -53,9 +53,8 @@ class XendDomain:
|
||||
# Hack alert. Python does not support mutual imports, but XendDomainInfo
|
||||
# needs access to the XendDomain instance to look up domains. Attempting
|
||||
# to import XendDomain from XendDomainInfo causes unbounded recursion.
|
||||
# So we stuff the XendDomain instance (self) into XendDomainInfo's
|
||||
# namespace as 'xd'.
|
||||
XendDomainInfo.xd = self
|
||||
# So we stuff the XendDomain instance (self) into xroot's components.
|
||||
xroot.add_component("xen.xend.XendDomain", self)
|
||||
# Table of domain info indexed by domain id.
|
||||
self.db = XendDB.XendDB(self.dbpath)
|
||||
self.domain_db = self.db.fetchall("")
|
||||
|
||||
@@ -27,6 +27,7 @@ import sxp
|
||||
import XendConsole
|
||||
xendConsole = XendConsole.instance()
|
||||
from XendLogging import log
|
||||
from XendRoot import get_component
|
||||
|
||||
import server.SrvDaemon
|
||||
xend = server.SrvDaemon.instance()
|
||||
@@ -460,7 +461,8 @@ class XendDomainInfo:
|
||||
if c in '_-.': continue
|
||||
if c in string.ascii_letters: continue
|
||||
raise VmError('invalid vm name')
|
||||
# See comment in XendDomain constructor about 'xd'.
|
||||
# See comment in XendDomain constructor.
|
||||
xd = get_component('xen.xend.XendDomain')
|
||||
if xd.domain_exists(name):
|
||||
raise VmError('vm name clash: ' + name)
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ class XendRoot:
|
||||
|
||||
loglevel_default = 'DEBUG'
|
||||
|
||||
components = {}
|
||||
|
||||
def __init__(self):
|
||||
self.rebooted = 0
|
||||
self.last_reboot = None
|
||||
@@ -62,6 +64,24 @@ class XendRoot:
|
||||
#eserver.subscribe('xend.domain.created', self.event_handler)
|
||||
#eserver.subscribe('xend.domain.died', self.event_handler)
|
||||
|
||||
def add_component(self, name, val):
|
||||
"""Add a xend component.
|
||||
|
||||
@param name: component name
|
||||
@param val: component object
|
||||
"""
|
||||
self.components[name] = val
|
||||
|
||||
def get_component(self, name):
|
||||
"""Get a xend component from its name.
|
||||
This is used as a work-round for problems caused by mutually
|
||||
recursive imports.
|
||||
|
||||
@param name: component name
|
||||
@return: component object (or None)
|
||||
"""
|
||||
return self.components.get(name)
|
||||
|
||||
def start(self):
|
||||
eserver.inject('xend.start', self.rebooted)
|
||||
|
||||
@@ -202,3 +222,9 @@ def instance():
|
||||
|
||||
def logger():
|
||||
return instance().get_logger()
|
||||
|
||||
def add_component(name, val):
|
||||
return instance().add_component(name, val)
|
||||
|
||||
def get_component(name):
|
||||
return instance().get_component(name)
|
||||
@@ -10,6 +10,7 @@ from xen.xend import Vifctl
|
||||
from xen.xend.XendError import XendError
|
||||
from xen.xend.XendLogging import log
|
||||
from xen.xend import XendVnet
|
||||
from xen.xend.XendRoot import get_component
|
||||
|
||||
import channel
|
||||
import controller
|
||||
@@ -168,8 +169,14 @@ class NetDev(controller.Dev):
|
||||
|
||||
def vifctl_params(self, vmname=None):
|
||||
dom = self.controller.dom
|
||||
name = vmname or ('DOM%d' % dom)
|
||||
return { 'domain': name,
|
||||
if vmname is None:
|
||||
xd = get_component('xen.xend.XendDomain')
|
||||
try:
|
||||
vm = xd.domain_lookup(dom)
|
||||
vmname = vm.name
|
||||
except:
|
||||
vmname = 'DOM%d' % dom
|
||||
return { 'domain': vmname,
|
||||
'vif' : self.get_vifname(),
|
||||
'mac' : self.get_mac(),
|
||||
'bridge': self.bridge,
|
||||
|
||||