Rename XendDomainInfo and DevController.getDomain to getDomid.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
emellor@ewan committed 2005-09-22 17:58:43 +01:00
1 parent 251888ee61
commit 089412c49e
5 files changed
+53 -53

No files matched your search

+35 -35
View File
@@ -179,13 +179,13 @@ class XendDomain:
@param info: domain info object
@param notify: send a domain created event if true
"""
if info.getDomain() in self.domains:
if info.getDomid() in self.domains:
notify = False
self.domains[info.getDomain()] = info
self.domains[info.getDomid()] = info
info.exportToDB(save=True)
if notify:
eserver.inject('xend.domain.create', [info.getName(),
info.getDomain()])
info.getDomid()])
def _delete_domain(self, id, notify=True):
"""Remove a domain from the tables.
@@ -200,7 +200,7 @@ class XendDomain:
info.delete()
if notify:
eserver.inject('xend.domain.died', [info.getName(),
info.getDomain()])
info.getDomid()])
# XXX this should not be needed
for domdb in self.dbmap.values():
if not domdb.has_key("xend"):
@@ -246,11 +246,11 @@ class XendDomain:
# Remove entries for domains that no longer exist.
# Update entries for existing domains.
for d in self.domains.values():
info = doms.get(d.getDomain())
info = doms.get(d.getDomid())
if info:
d.update(info)
elif not d.restart_pending():
self._delete_domain(d.getDomain())
self._delete_domain(d.getDomid())
def update_domain(self, id):
"""Update information for a single domain.
@@ -281,22 +281,22 @@ class XendDomain:
@param dominfo: domain object
"""
log.info("Restarting domain: name=%s id=%s", dominfo.getName(),
dominfo.getDomain())
dominfo.getDomid())
eserver.inject("xend.domain.restart",
[dominfo.getName(), dominfo.getDomain(), "begin"])
[dominfo.getName(), dominfo.getDomid(), "begin"])
try:
dominfo.restart()
log.info('Restarted domain name=%s id=%s', dominfo.getName(),
dominfo.getDomain())
dominfo.getDomid())
eserver.inject("xend.domain.restart",
[dominfo.getName(), dominfo.getDomain(),
[dominfo.getName(), dominfo.getDomid(),
"success"])
self.domain_unpause(dominfo.getDomain())
self.domain_unpause(dominfo.getDomid())
except Exception, ex:
log.exception("Exception restarting domain: name=%s id=%s",
dominfo.getName(), dominfo.getDomain())
dominfo.getName(), dominfo.getDomid())
eserver.inject("xend.domain.restart",
[dominfo.getName(), dominfo.getDomain(), "fail"])
[dominfo.getName(), dominfo.getDomid(), "fail"])
return dominfo
def domain_configure(self, config):
@@ -386,9 +386,9 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
eserver.inject('xend.domain.unpause', [dominfo.getName(),
dominfo.getDomain()])
dominfo.getDomid()])
try:
return xc.domain_unpause(dom=dominfo.getDomain())
return xc.domain_unpause(dom=dominfo.getDomid())
except Exception, ex:
raise XendError(str(ex))
@@ -399,9 +399,9 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
eserver.inject('xend.domain.pause', [dominfo.getName(),
dominfo.getDomain()])
dominfo.getDomid()])
try:
return xc.domain_pause(dom=dominfo.getDomain())
return xc.domain_pause(dom=dominfo.getDomid())
except Exception, ex:
raise XendError(str(ex))
@@ -417,9 +417,9 @@ class XendDomain:
@param reason: shutdown type: poweroff, reboot, suspend, halt
"""
dominfo = self.domain_lookup(id)
self.domain_restart_schedule(dominfo.getDomain(), reason, force=True)
self.domain_restart_schedule(dominfo.getDomid(), reason, force=True)
eserver.inject('xend.domain.shutdown', [dominfo.getName(),
dominfo.getDomain(), reason])
dominfo.getDomid(), reason])
if reason == 'halt':
reason = 'poweroff'
val = dominfo.shutdown(reason)
@@ -443,7 +443,7 @@ class XendDomain:
if not dominfo.shutdown_pending:
# domain doesn't need shutdown
continue
id = dominfo.getDomain()
id = dominfo.getDomid()
left = dominfo.shutdown_time_left(SHUTDOWN_TIMEOUT)
if left <= 0:
# Shutdown expired - destroy domain.
@@ -474,16 +474,16 @@ class XendDomain:
restart = (force and reason == 'reboot') or dominfo.restart_needed(reason)
if restart:
log.info('Scheduling restart for domain: name=%s id=%s',
dominfo.getName(), dominfo.getDomain())
dominfo.getName(), dominfo.getDomid())
eserver.inject("xend.domain.restart",
[dominfo.getName(), dominfo.getDomain(),
[dominfo.getName(), dominfo.getDomid(),
"schedule"])
dominfo.restarting()
else:
log.info('Cancelling restart for domain: name=%s id=%s',
dominfo.getName(), dominfo.getDomain())
dominfo.getName(), dominfo.getDomid())
eserver.inject("xend.domain.restart",
[dominfo.getName(), dominfo.getDomain(), "cancel"])
[dominfo.getName(), dominfo.getDomid(), "cancel"])
dominfo.restart_cancel()
def domain_restarts(self):
@@ -493,7 +493,7 @@ class XendDomain:
for dominfo in self.domains.values():
if not dominfo.restart_pending():
continue
info = doms.get(dominfo.getDomain())
info = doms.get(dominfo.getDomid())
if info:
# Don't execute restart for domains still running.
continue
@@ -578,7 +578,7 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
try:
return xc.domain_pincpu(dominfo.getDomain(), vcpu, cpumap)
return xc.domain_pincpu(dominfo.getDomid(), vcpu, cpumap)
except Exception, ex:
raise XendError(str(ex))
@@ -587,7 +587,7 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
try:
return xc.bvtsched_domain_set(dom=dominfo.getDomain(),
return xc.bvtsched_domain_set(dom=dominfo.getDomid(),
mcuadv=mcuadv,
warpback=warpback,
warpvalue=warpvalue,
@@ -600,7 +600,7 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
try:
return xc.bvtsched_domain_get(dominfo.getDomain())
return xc.bvtsched_domain_get(dominfo.getDomid())
except Exception, ex:
raise XendError(str(ex))
@@ -610,7 +610,7 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
try:
return xc.sedf_domain_set(dominfo.getDomain(), period, slice,
return xc.sedf_domain_set(dominfo.getDomid(), period, slice,
latency, extratime, weight)
except Exception, ex:
raise XendError(str(ex))
@@ -620,7 +620,7 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
try:
return xc.sedf_domain_get(dominfo.getDomain())
return xc.sedf_domain_get(dominfo.getDomid())
except Exception, ex:
raise XendError(str(ex))
@@ -709,7 +709,7 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
try:
return xc.shadow_control(dominfo.getDomain(), op)
return xc.shadow_control(dominfo.getDomid(), op)
except Exception, ex:
raise XendError(str(ex))
@@ -723,7 +723,7 @@ class XendDomain:
dominfo = self.domain_lookup(id)
maxmem = int(mem) * 1024
try:
return xc.domain_setmaxmem(dominfo.getDomain(),
return xc.domain_setmaxmem(dominfo.getDomid(),
maxmem_kb = maxmem)
except Exception, ex:
raise XendError(str(ex))
@@ -757,12 +757,12 @@ class XendDomain:
"""
dominfo = self.domain_lookup(id)
corefile = "/var/xen/dump/%s.%s.core" % (dominfo.getName(),
dominfo.getDomain())
dominfo.getDomid())
try:
xc.domain_dumpcore(dom=dominfo.getDomain(), corefile=corefile)
xc.domain_dumpcore(dom=dominfo.getDomid(), corefile=corefile)
except Exception, ex:
log.warning("Dumpcore failed, id=%s name=%s: %s",
dominfo.getDomain(), dominfo.getName(), ex)
dominfo.getDomid(), dominfo.getName(), ex)
def instance():
"""Singleton constructor. Use this instead of the class constructor.
+1 -1
View File
@@ -474,7 +474,7 @@ class XendDomainInfo:
self.domid = domid
self.storeDom("domid", self.domid)
def getDomain(self):
def getDomid(self):
return self.domid
def setName(self, name):
+10 -10
View File
@@ -161,14 +161,14 @@ class ImageHandler:
raise VmError('Kernel ramdisk does not exist: %s' % self.ramdisk)
if len(self.cmdline) >= MAX_GUEST_CMDLINE:
log.warning('kernel cmdline too long, domain %d',
self.vm.getDomain())
self.vm.getDomid())
log.info("buildDomain os=%s dom=%d vcpus=%d", self.ostype,
self.vm.getDomain(), self.vm.getVCpuCount())
self.vm.getDomid(), self.vm.getVCpuCount())
err = self.buildDomain()
if err != 0:
raise VmError('Building domain failed: ostype=%s dom=%d err=%d'
% (self.ostype, self.vm.getDomain(), err))
% (self.ostype, self.vm.getDomid(), err))
def getDomainMemory(self, mem):
"""@return The memory required, in KiB, by the domain to store the
@@ -210,7 +210,7 @@ class LinuxImageHandler(ImageHandler):
else:
console_evtchn = 0
log.debug("dom = %d", self.vm.getDomain())
log.debug("dom = %d", self.vm.getDomid())
log.debug("image = %s", self.kernel)
log.debug("store_evtchn = %d", store_evtchn)
log.debug("console_evtchn = %d", console_evtchn)
@@ -219,7 +219,7 @@ class LinuxImageHandler(ImageHandler):
log.debug("flags = %d", self.flags)
log.debug("vcpus = %d", self.vm.getVCpuCount())
ret = xc.linux_build(dom = self.vm.getDomain(),
ret = xc.linux_build(dom = self.vm.getDomid(),
image = self.kernel,
store_evtchn = store_evtchn,
console_evtchn = console_evtchn,
@@ -266,14 +266,14 @@ class VmxImageHandler(ImageHandler):
def buildDomain(self):
# Create an event channel
self.device_channel = channel.eventChannel(0, self.vm.getDomain())
self.device_channel = channel.eventChannel(0, self.vm.getDomid())
log.info("VMX device model port: %d", self.device_channel.port2)
if self.vm.store_channel:
store_evtchn = self.vm.store_channel.port2
else:
store_evtchn = 0
log.debug("dom = %d", self.vm.getDomain())
log.debug("dom = %d", self.vm.getDomid())
log.debug("image = %s", self.kernel)
log.debug("control_evtchn = %d", self.device_channel.port2)
log.debug("store_evtchn = %d", store_evtchn)
@@ -284,7 +284,7 @@ class VmxImageHandler(ImageHandler):
log.debug("flags = %d", self.flags)
log.debug("vcpus = %d", self.vm.getVCpuCount())
ret = xc.vmx_build(dom = self.vm.getDomain(),
ret = xc.vmx_build(dom = self.vm.getDomid(),
image = self.kernel,
control_evtchn = self.device_channel.port2,
store_evtchn = store_evtchn,
@@ -370,7 +370,7 @@ class VmxImageHandler(ImageHandler):
elif vnc:
ret = ret + ['-vnc', '-k', 'en-us']
if vnc:
vncport = int(self.vm.getDomain()) + 5900
vncport = int(self.vm.getDomid()) + 5900
ret = ret + ['-vncport', '%d' % vncport]
return ret
@@ -384,7 +384,7 @@ class VmxImageHandler(ImageHandler):
vnc = self.vncParams()
if len(vnc):
args = args + vnc
args = args + ([ "-d", "%d" % self.vm.getDomain(),
args = args + ([ "-d", "%d" % self.vm.getDomid(),
"-p", "%d" % self.device_channel.port1,
"-m", "%s" % (self.vm.getMemoryTarget() / 1024)])
args = args + self.dmargs
@@ -84,7 +84,7 @@ class DevController:
def sxpr(self, devid):
"""@return an s-expression describing the specified device.
"""
return [self.deviceClass, ['dom', self.vm.getDomain(),
return [self.deviceClass, ['dom', self.vm.getDomid(),
'id', devid]]
@@ -110,11 +110,11 @@ class DevController:
raise NotImplementedError()
def getDomain(self):
"""Stub to {@link XendDomainInfo.getDomain}, for use by our
def getDomid(self):
"""Stub to {@link XendDomainInfo.getDomid}, for use by our
subclasses.
"""
return self.vm.getDomain()
return self.vm.getDomid()
def allocateDeviceID(self):
@@ -167,14 +167,14 @@ class DevController:
frontDetails.update({
'backend' : backpath,
'backend-id' : "%i" % backdom.getDomain()
'backend-id' : "%i" % backdom.getDomid()
})
backDetails.update({
'domain' : self.vm.getName(),
'frontend' : frontpath,
'frontend-id' : "%i" % self.vm.getDomain()
'frontend-id' : "%i" % self.vm.getDomid()
})
log.debug('DevController: writing %s to %s.', str(frontDetails),
+1 -1
View File
@@ -68,7 +68,7 @@ class PciController(DevController):
dev = get_param('dev')
func = get_param('func')
rc = xc.physdev_pci_access_modify(dom = self.getDomain(),
rc = xc.physdev_pci_access_modify(dom = self.getDomid(),
bus = bus,
dev = dev,
func = func,
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.