mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
bitkeeper revision 1.1662.1.3 (42a41e76cPOoyKvX4mmcf2J0DTpnpA)
Many files: Cleanup domain id/name confusion. XendDomain.py: Cleanup domain id/name confusion, interface to xend db and domain_lookup. Signed-off-by: Mike Wray <mike.wray@hp.com> Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
This commit is contained in:
1 parent
57fbe22719
commit
31164a82a2
8 files changed
+110
-118
No files matched your search
@@ -43,7 +43,7 @@ def save(xd, fd, dominfo):
|
||||
write_exact(fd, config, "could not write guest state file: config")
|
||||
|
||||
cmd = [PATH_XC_SAVE, str(xc.handle()), str(fd),
|
||||
dominfo.id]
|
||||
str(dominfo.id)]
|
||||
log.info("[xc_save] " + join(cmd))
|
||||
child = xPopen3(cmd, True, -1, [fd, xc.handle()])
|
||||
|
||||
@@ -109,7 +109,7 @@ def restore(xd, fd):
|
||||
"not a valid guest state file: pfn count out of range")
|
||||
|
||||
cmd = [PATH_XC_RESTORE, str(xc.handle()), str(fd),
|
||||
dominfo.id, str(nr_pfns)]
|
||||
str(dominfo.id), str(nr_pfns)]
|
||||
log.info("[xc_restore] " + join(cmd))
|
||||
child = xPopen3(cmd, True, -1, [fd, xc.handle()])
|
||||
child.tochild.close()
|
||||
|
||||
@@ -78,7 +78,7 @@ class XendDomain:
|
||||
domlist = xc.domain_getinfo()
|
||||
doms = {}
|
||||
for d in domlist:
|
||||
domid = str(d['dom'])
|
||||
domid = d['dom']
|
||||
doms[domid] = d
|
||||
return doms
|
||||
|
||||
@@ -86,12 +86,8 @@ class XendDomain:
|
||||
"""Get info about a single domain from xc.
|
||||
Returns None if not found.
|
||||
|
||||
@param dom domain id
|
||||
@param dom domain id (int)
|
||||
"""
|
||||
try:
|
||||
dom = int(dom)
|
||||
except ValueError:
|
||||
return None
|
||||
dominfo = xc.domain_getinfo(dom, 1)
|
||||
if dominfo == [] or dominfo[0]['dom'] != dom:
|
||||
dominfo = None
|
||||
@@ -104,13 +100,12 @@ class XendDomain:
|
||||
"""
|
||||
doms = self.xen_domains()
|
||||
for config in self.db.fetchall("").values():
|
||||
domid = str(sxp.child_value(config, 'id'))
|
||||
domid = int(sxp.child_value(config, 'id'))
|
||||
if domid in doms:
|
||||
try:
|
||||
self._new_domain(config, doms[domid])
|
||||
self.update_domain(domid)
|
||||
except Exception, ex:
|
||||
log.exception("Error recreating domain info: id=%s", domid)
|
||||
log.exception("Error recreating domain info: id=%d", domid)
|
||||
self._delete_domain(domid)
|
||||
else:
|
||||
self._delete_domain(domid)
|
||||
@@ -121,7 +116,7 @@ class XendDomain:
|
||||
|
||||
info domain info
|
||||
"""
|
||||
self.db.save(info.id, info.sxpr())
|
||||
self.db.save(str(info.id), info.sxpr())
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
@@ -135,6 +130,7 @@ class XendDomain:
|
||||
"""
|
||||
dominfo = XendDomainInfo.recreate(savedinfo, info)
|
||||
self.domains[dominfo.id] = dominfo
|
||||
self.sync_domain(dominfo)
|
||||
return dominfo
|
||||
|
||||
def _add_domain(self, info, notify=True):
|
||||
@@ -147,7 +143,7 @@ class XendDomain:
|
||||
for i, d in self.domains.items():
|
||||
if i != d.id:
|
||||
del self.domains[i]
|
||||
self.db.delete(i)
|
||||
self.db.delete(str(i))
|
||||
if info.id in self.domains:
|
||||
notify = False
|
||||
self.domains[info.id] = info
|
||||
@@ -166,7 +162,7 @@ class XendDomain:
|
||||
del self.domains[id]
|
||||
if notify:
|
||||
eserver.inject('xend.domain.died', [info.name, info.id])
|
||||
self.db.delete(id)
|
||||
self.db.delete(str(id))
|
||||
|
||||
def reap(self):
|
||||
"""Look for domains that have crashed or stopped.
|
||||
@@ -181,22 +177,21 @@ class XendDomain:
|
||||
not(d['running'] or d['paused'] or d['blocked']))
|
||||
if dead:
|
||||
casualties.append(d)
|
||||
destroyed = 0
|
||||
for d in casualties:
|
||||
id = str(d['dom'])
|
||||
id = d['dom']
|
||||
#print 'reap>', id
|
||||
dominfo = self.domains.get(id)
|
||||
name = (dominfo and dominfo.name) or '??'
|
||||
if dominfo and dominfo.is_terminated():
|
||||
#print 'reap> already terminated:', id
|
||||
continue
|
||||
log.debug('XendDomain>reap> domain died name=%s id=%s', name, id)
|
||||
log.debug('XendDomain>reap> domain died name=%s id=%d', name, id)
|
||||
if d['shutdown']:
|
||||
reason = shutdown_reason(d['shutdown_reason'])
|
||||
log.debug('XendDomain>reap> shutdown name=%s id=%s reason=%s', name, id, reason)
|
||||
log.debug('XendDomain>reap> shutdown name=%s id=%d reason=%s', name, id, reason)
|
||||
if reason in ['suspend']:
|
||||
if dominfo and dominfo.is_terminated():
|
||||
log.debug('XendDomain>reap> Suspended domain died id=%s', id)
|
||||
log.debug('XendDomain>reap> Suspended domain died id=%d', id)
|
||||
else:
|
||||
eserver.inject('xend.domain.suspended', [name, id])
|
||||
if dominfo:
|
||||
@@ -207,9 +202,8 @@ class XendDomain:
|
||||
self.domain_restart_schedule(id, reason)
|
||||
else:
|
||||
if xroot.get_enable_dump():
|
||||
self.domain_dumpcore(int(id))
|
||||
self.domain_dumpcore(id)
|
||||
eserver.inject('xend.domain.exit', [name, id, 'crash'])
|
||||
destroyed += 1
|
||||
self.final_domain_destroy(id)
|
||||
|
||||
def refresh(self, cleanup=False):
|
||||
@@ -237,16 +231,7 @@ class XendDomain:
|
||||
scheduler.now(self.domain_restarts)
|
||||
|
||||
def update_domain(self, id):
|
||||
"""Update the saved info for a domain.
|
||||
|
||||
@param id: domain id
|
||||
"""
|
||||
dominfo = self.domains.get(id)
|
||||
if dominfo:
|
||||
self.sync_domain(dominfo)
|
||||
|
||||
def refresh_domain(self, id):
|
||||
"""Refresh information for a single domain.
|
||||
"""Update information for a single domain.
|
||||
|
||||
@param id: domain id
|
||||
"""
|
||||
@@ -339,22 +324,30 @@ class XendDomain:
|
||||
@param id: domain id
|
||||
@return: domain object (or None)
|
||||
"""
|
||||
id = str(id)
|
||||
self.refresh_domain(id)
|
||||
self.update_domain(id)
|
||||
return self.domains.get(id)
|
||||
|
||||
def domain_lookup(self, id):
|
||||
name = str(id)
|
||||
dominfo = self.domains.get_by_name(name) or self.domains.get(id)
|
||||
dominfo = self.domains.get(id)
|
||||
if not dominfo:
|
||||
try:
|
||||
info = self.xen_domain(id)
|
||||
if info:
|
||||
log.info("Creating entry for unknown domain: id=%s", name)
|
||||
log.info("Creating entry for unknown domain: id=%d", id)
|
||||
dominfo = XendDomainInfo.recreate(None, info, unknown=True)
|
||||
self._add_domain(dominfo)
|
||||
except Exception, ex:
|
||||
log.exception("Error creating domain info: id=%s", name)
|
||||
log.exception("Error creating domain info: id=%d", id)
|
||||
return dominfo
|
||||
|
||||
def domain_lookup_by_name(self, name):
|
||||
dominfo = self.domains.get_by_name(name)
|
||||
if not dominfo:
|
||||
try:
|
||||
id = int(name)
|
||||
dominfo = self.domain_lookup(id)
|
||||
except ValueError:
|
||||
pass
|
||||
return dominfo
|
||||
|
||||
def domain_unpause(self, id):
|
||||
@@ -365,7 +358,7 @@ class XendDomain:
|
||||
dominfo = self.domain_lookup(id)
|
||||
eserver.inject('xend.domain.unpause', [dominfo.name, dominfo.id])
|
||||
try:
|
||||
return xc.domain_unpause(dom=dominfo.dom)
|
||||
return xc.domain_unpause(dom=dominfo.id)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
@@ -377,7 +370,7 @@ class XendDomain:
|
||||
dominfo = self.domain_lookup(id)
|
||||
eserver.inject('xend.domain.pause', [dominfo.name, dominfo.id])
|
||||
try:
|
||||
return xc.domain_pause(dom=dominfo.dom)
|
||||
return xc.domain_pause(dom=dominfo.id)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
@@ -435,7 +428,7 @@ class XendDomain:
|
||||
@param id: domain id
|
||||
@param reason: shutdown reason
|
||||
"""
|
||||
log.debug('domain_restart_schedule> %s %s %d', id, reason, force)
|
||||
log.debug('domain_restart_schedule> %d %s %d', id, reason, force)
|
||||
dominfo = self.domain_lookup(id)
|
||||
if not dominfo:
|
||||
return
|
||||
@@ -483,7 +476,7 @@ class XendDomain:
|
||||
except:
|
||||
#todo
|
||||
try:
|
||||
val = xc.domain_destroy(dom=int(id))
|
||||
val = xc.domain_destroy(dom=id)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
return val
|
||||
@@ -552,7 +545,7 @@ class XendDomain:
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
try:
|
||||
return xc.domain_pincpu(int(dominfo.id), vcpu, cpumap)
|
||||
return xc.domain_pincpu(dominfo.id, vcpu, cpumap)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
@@ -561,7 +554,7 @@ class XendDomain:
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
try:
|
||||
return xc.bvtsched_domain_set(dom=dominfo.dom, mcuadv=mcuadv,
|
||||
return xc.bvtsched_domain_set(dom=dominfo.id, mcuadv=mcuadv,
|
||||
warpback=warpback, warpvalue=warpvalue,
|
||||
warpl=warpl, warpu=warpu)
|
||||
except Exception, ex:
|
||||
@@ -572,7 +565,7 @@ class XendDomain:
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
try:
|
||||
return xc.bvtsched_domain_get(dominfo.dom)
|
||||
return xc.bvtsched_domain_get(dominfo.id)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
@@ -580,18 +573,18 @@ class XendDomain:
|
||||
def domain_cpu_sedf_set(self, id, period, slice, latency, extratime, weight):
|
||||
"""Set Simple EDF scheduler parameters for a domain.
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
dominfo = self.domain_lookup(id)
|
||||
try:
|
||||
return xc.sedf_domain_set(dominfo.dom, period, slice, latency, extratime, weight)
|
||||
return xc.sedf_domain_set(dominfo.id, period, slice, latency, extratime, weight)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
def domain_cpu_sedf_get(self, id):
|
||||
"""Get Atropos scheduler parameters for a domain.
|
||||
"""Get Simple EDF scheduler parameters for a domain.
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
try:
|
||||
return xc.sedf_domain_get(dominfo.dom)
|
||||
return xc.sedf_domain_get(dominfo.id)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
@@ -603,44 +596,44 @@ class XendDomain:
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
val = dominfo.device_create(devconfig)
|
||||
self.update_domain(dominfo.id)
|
||||
self.sync_domain(dominfo)
|
||||
return val
|
||||
|
||||
def domain_device_configure(self, id, devconfig, idx):
|
||||
def domain_device_configure(self, id, devconfig, devid):
|
||||
"""Configure an existing device for a domain.
|
||||
|
||||
@param id: domain id
|
||||
@param devconfig: device configuration
|
||||
@param idx: device index
|
||||
@param devid: device index
|
||||
@return: updated device configuration
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
val = dominfo.device_configure(devconfig, idx)
|
||||
self.update_domain(dominfo.id)
|
||||
val = dominfo.device_configure(devconfig, devid)
|
||||
self.sync_domain(dominfo)
|
||||
return val
|
||||
|
||||
def domain_device_refresh(self, id, type, idx):
|
||||
def domain_device_refresh(self, id, type, devid):
|
||||
"""Refresh a device.
|
||||
|
||||
@param id: domain id
|
||||
@param idx: device index
|
||||
@param devid: device index
|
||||
@param type: device type
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
val = dominfo.device_refresh(type, idx)
|
||||
self.update_domain(dominfo.id)
|
||||
val = dominfo.device_refresh(type, devid)
|
||||
self.sync_domain(dominfo)
|
||||
return val
|
||||
|
||||
def domain_device_destroy(self, id, type, idx):
|
||||
def domain_device_destroy(self, id, type, devid):
|
||||
"""Destroy a device.
|
||||
|
||||
@param id: domain id
|
||||
@param idx: device index
|
||||
@param devid: device index
|
||||
@param type: device type
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
val = dominfo.device_destroy(type, idx)
|
||||
self.update_domain(dominfo.id)
|
||||
val = dominfo.device_destroy(type, devid)
|
||||
self.sync_domain(dominfo)
|
||||
return val
|
||||
|
||||
def domain_devtype_ls(self, id, type):
|
||||
@@ -653,16 +646,16 @@ class XendDomain:
|
||||
dominfo = self.domain_lookup(id)
|
||||
return dominfo.getDeviceSxprs(type)
|
||||
|
||||
def domain_devtype_get(self, id, type, idx):
|
||||
def domain_devtype_get(self, id, type, devid):
|
||||
"""Get a device from a domain.
|
||||
|
||||
@param id: domain
|
||||
@param type: device type
|
||||
@param idx: device index
|
||||
@param devid: device index
|
||||
@return: device object (or None)
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
return dominfo.getDeviceByIndex(type, idx)
|
||||
return dominfo.getDeviceByIndex(type, devid)
|
||||
|
||||
def domain_vif_limit_set(self, id, vif, credit, period):
|
||||
"""Limit the vif's transmission rate
|
||||
@@ -681,33 +674,33 @@ class XendDomain:
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
try:
|
||||
return xc.shadow_control(dominfo.dom, op)
|
||||
return xc.shadow_control(dominfo.id, op)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
def domain_maxmem_set(self, id, mem):
|
||||
"""Set the memory limit for a domain.
|
||||
|
||||
@param dom: domain
|
||||
@param id: domain
|
||||
@param mem: memory limit (in MB)
|
||||
@return: 0 on success, -1 on error
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
maxmem = int(mem) * 1024
|
||||
try:
|
||||
return xc.domain_setmaxmem(dominfo.dom, maxmem_kb = maxmem)
|
||||
return xc.domain_setmaxmem(dominfo.id, maxmem_kb = maxmem)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
def domain_mem_target_set(self, id, target):
|
||||
def domain_mem_target_set(self, id, mem):
|
||||
"""Set the memory target for a domain.
|
||||
|
||||
@param id: domain
|
||||
@param target: memory target (in MB)
|
||||
@param mem: memory target (in MB)
|
||||
@return: 0 on success, -1 on error
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
return dominfo.mem_target_set(target)
|
||||
return dominfo.mem_target_set(mem)
|
||||
|
||||
def domain_dumpcore(self, id):
|
||||
"""Save a core dump for a crashed domain.
|
||||
|
||||
@@ -86,7 +86,7 @@ STATE_VM_SUSPENDED = "suspended"
|
||||
def domain_exists(name):
|
||||
# See comment in XendDomain constructor.
|
||||
xd = get_component('xen.xend.XendDomain')
|
||||
return xd.domain_lookup(name)
|
||||
return xd.domain_lookup_by_name(name)
|
||||
|
||||
def shutdown_reason(code):
|
||||
"""Get a shutdown reason from a code.
|
||||
@@ -248,7 +248,6 @@ class XendDomainInfo:
|
||||
|
||||
self.config = None
|
||||
self.id = None
|
||||
self.dom = None
|
||||
self.cpu_weight = 1
|
||||
self.start_time = None
|
||||
self.name = None
|
||||
@@ -290,11 +289,10 @@ class XendDomainInfo:
|
||||
|
||||
@param dom: domain id
|
||||
"""
|
||||
self.dom = int(dom)
|
||||
self.id = str(dom)
|
||||
self.id = int(dom)
|
||||
|
||||
def getDomain(self):
|
||||
return self.dom
|
||||
return self.id
|
||||
|
||||
def getName(self):
|
||||
return self.name
|
||||
@@ -484,7 +482,7 @@ class XendDomainInfo:
|
||||
return
|
||||
if dominfo.is_terminated():
|
||||
return
|
||||
if not self.dom or (dominfo.dom != self.dom):
|
||||
if not self.id or (dominfo.id != self.id):
|
||||
raise VmError('vm name clash: ' + name)
|
||||
|
||||
def construct(self, config):
|
||||
@@ -532,8 +530,8 @@ class XendDomainInfo:
|
||||
if self.memory is None:
|
||||
raise VmError('missing memory size')
|
||||
cpu = sxp.child_value(config, 'cpu')
|
||||
if self.recreate and self.dom and cpu is not None and int(cpu) >= 0:
|
||||
xc.domain_pincpu(self.dom, 0, 1<<int(cpu))
|
||||
if self.recreate and self.id and cpu is not None and int(cpu) >= 0:
|
||||
xc.domain_pincpu(self.id, 0, 1<<int(cpu))
|
||||
try:
|
||||
image = sxp.child_value(self.config, 'image')
|
||||
vcpus = sxp.child_value(image, 'vcpus')
|
||||
@@ -622,9 +620,9 @@ class XendDomainInfo:
|
||||
if self.channel:
|
||||
self.channel.close()
|
||||
self.channel = None
|
||||
if self.dom is None: return 0
|
||||
if self.id is None: return 0
|
||||
try:
|
||||
return xc.domain_destroy(dom=self.dom)
|
||||
return xc.domain_destroy(dom=self.id)
|
||||
except Exception, err:
|
||||
log.exception("Domain destroy failed: %s", self.name)
|
||||
|
||||
@@ -652,7 +650,7 @@ class XendDomainInfo:
|
||||
def show(self):
|
||||
"""Print virtual machine info.
|
||||
"""
|
||||
print "[VM dom=%d name=%s memory=%d" % (self.dom, self.name, self.memory)
|
||||
print "[VM dom=%d name=%s memory=%d" % (self.id, self.name, self.memory)
|
||||
print "image:"
|
||||
sxp.show(self.image)
|
||||
print
|
||||
@@ -671,7 +669,7 @@ class XendDomainInfo:
|
||||
self.start_time = time.time()
|
||||
if self.restore:
|
||||
return
|
||||
dom = self.dom or 0
|
||||
dom = self.id or 0
|
||||
memory = self.memory
|
||||
try:
|
||||
cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
|
||||
@@ -707,8 +705,8 @@ class XendDomainInfo:
|
||||
if ramdisk and not os.path.isfile(ramdisk):
|
||||
raise VmError('Kernel ramdisk does not exist: %s' % ramdisk)
|
||||
if len(cmdline) >= 256:
|
||||
log.warning('kernel cmdline too long, domain %d', self.dom)
|
||||
dom = self.dom
|
||||
log.warning('kernel cmdline too long, domain %d', self.id)
|
||||
dom = self.id
|
||||
buildfn = getattr(xc, '%s_build' % ostype)
|
||||
flags = 0
|
||||
if self.netif_backend: flags |= SIF_NET_BE_DOMAIN
|
||||
@@ -763,7 +761,7 @@ class XendDomainInfo:
|
||||
if info:
|
||||
local = int(sxp.child_value(info, "local_port", 0))
|
||||
remote = int(sxp.child_value(info, "remote_port", 1))
|
||||
self.channel = channelFactory().openChannel(self.dom,
|
||||
self.channel = channelFactory().openChannel(str(self.id),
|
||||
local_port=local,
|
||||
remote_port=remote)
|
||||
|
||||
@@ -810,7 +808,7 @@ class XendDomainInfo:
|
||||
#todo: self.memory?
|
||||
memory = sxp.child_value(self.config, "memory")
|
||||
# Create an event channel
|
||||
device_channel = channel.eventChannel(0, self.dom)
|
||||
device_channel = channel.eventChannel(0, self.id)
|
||||
# see if a vncviewer was specified
|
||||
# XXX RN: bit of a hack. should unify this, maybe stick in config space
|
||||
vncconnect=""
|
||||
@@ -830,7 +828,7 @@ class XendDomainInfo:
|
||||
os.system(device_model
|
||||
+ " -f %s" % device_config
|
||||
+ vncconnect
|
||||
+ " -d %d" % self.dom
|
||||
+ " -d %d" % self.id
|
||||
+ " -p %d" % device_channel['port1']
|
||||
+ " -m %s" % memory)
|
||||
|
||||
@@ -1222,7 +1220,7 @@ def vm_field_maxmem(vm, config, val, index):
|
||||
maxmem = int(maxmem)
|
||||
except:
|
||||
raise VmError("invalid maxmem: " + str(maxmem))
|
||||
xc.domain_setmaxmem(vm.dom, maxmem_kb = maxmem * 1024)
|
||||
xc.domain_setmaxmem(vm.id, maxmem_kb = maxmem * 1024)
|
||||
|
||||
#============================================================================
|
||||
# Register image handlers.
|
||||
|
||||
@@ -30,7 +30,7 @@ class SrvConsole(SrvDir):
|
||||
#self.ls()
|
||||
req.write('<p>%s</p>' % self.info)
|
||||
req.write('<p><a href="%s">Connect to domain %d</a></p>'
|
||||
% (self.info.uri(), self.info.dom))
|
||||
% (self.info.uri(), self.info.id))
|
||||
self.form(req)
|
||||
req.write('</body></html>')
|
||||
|
||||
|
||||
@@ -28,19 +28,19 @@ class SrvDomain(SrvDir):
|
||||
fn = FormFn(self.xd.domain_configure,
|
||||
[['dom', 'int'],
|
||||
['config', 'sxpr']])
|
||||
return fn(req.args, {'dom': self.dom.dom})
|
||||
return fn(req.args, {'dom': self.dom.id})
|
||||
|
||||
def op_unpause(self, op, req):
|
||||
val = self.xd.domain_unpause(self.dom.name)
|
||||
val = self.xd.domain_unpause(self.dom.id)
|
||||
return val
|
||||
|
||||
def op_pause(self, op, req):
|
||||
val = self.xd.domain_pause(self.dom.name)
|
||||
val = self.xd.domain_pause(self.dom.id)
|
||||
return val
|
||||
|
||||
def op_shutdown(self, op, req):
|
||||
fn = FormFn(self.xd.domain_shutdown,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['reason', 'str'],
|
||||
['key', 'int']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
@@ -50,7 +50,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_destroy(self, op, req):
|
||||
fn = FormFn(self.xd.domain_destroy,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['reason', 'str']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
req.setHeader("Location", "%s/.." % req.prePathURL())
|
||||
@@ -61,7 +61,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def do_save(self, op, req):
|
||||
fn = FormFn(self.xd.domain_save,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['file', 'str']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
return 0
|
||||
@@ -71,7 +71,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def do_migrate(self, op, req):
|
||||
fn = FormFn(self.xd.domain_migrate,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['destination', 'str'],
|
||||
['live', 'int'],
|
||||
['resource', 'int']])
|
||||
@@ -79,7 +79,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_pincpu(self, op, req):
|
||||
fn = FormFn(self.xd.domain_pincpu,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['vcpu', 'int'],
|
||||
['cpumap', 'int']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
@@ -87,7 +87,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_cpu_bvt_set(self, op, req):
|
||||
fn = FormFn(self.xd.domain_cpu_bvt_set,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['mcuadv', 'int'],
|
||||
['warpback', 'int'],
|
||||
['warpvalue', 'int'],
|
||||
@@ -99,7 +99,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_cpu_sedf_set(self, op, req):
|
||||
fn = FormFn(self.xd.domain_cpu_sedf_set,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['period', 'int'],
|
||||
['slice', 'int'],
|
||||
['latency', 'int'],
|
||||
@@ -110,28 +110,28 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_maxmem_set(self, op, req):
|
||||
fn = FormFn(self.xd.domain_maxmem_set,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['memory', 'int']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
return val
|
||||
|
||||
def op_mem_target_set(self, op, req):
|
||||
fn = FormFn(self.xd.domain_mem_target_set,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['target', 'int']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
return val
|
||||
|
||||
def op_devices(self, op, req):
|
||||
fn = FormFn(self.xd.domain_devtype_ls,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['type', 'str']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
return val
|
||||
|
||||
def op_device(self, op, req):
|
||||
fn = FormFn(self.xd.domain_devtype_get,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['type', 'str'],
|
||||
['idx', 'int']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
@@ -142,14 +142,14 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_device_create(self, op, req):
|
||||
fn = FormFn(self.xd.domain_device_create,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['config', 'sxpr']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
return val
|
||||
|
||||
def op_device_refresh(self, op, req):
|
||||
fn = FormFn(self.xd.domain_device_refresh,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['type', 'str'],
|
||||
['idx', 'str']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
@@ -157,7 +157,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_device_destroy(self, op, req):
|
||||
fn = FormFn(self.xd.domain_device_destroy,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['type', 'str'],
|
||||
['idx', 'str']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
@@ -165,7 +165,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_device_configure(self, op, req):
|
||||
fn = FormFn(self.xd.domain_device_configure,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['config', 'sxpr'],
|
||||
['idx', 'str']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
@@ -173,7 +173,7 @@ class SrvDomain(SrvDir):
|
||||
|
||||
def op_vif_limit_set(self, op, req):
|
||||
fn = FormFn(self.xd.domain_vif_limit_set,
|
||||
[['dom', 'str'],
|
||||
[['dom', 'int'],
|
||||
['vif', 'int'],
|
||||
['credit', 'int'],
|
||||
['period', 'int']])
|
||||
|
||||
@@ -24,7 +24,7 @@ class SrvDomainDir(SrvDir):
|
||||
|
||||
def domain(self, x):
|
||||
val = None
|
||||
dom = self.xd.domain_lookup(x)
|
||||
dom = self.xd.domain_lookup_by_name(x)
|
||||
if not dom:
|
||||
raise XendError('No such domain ' + str(x))
|
||||
val = SrvDomain(dom)
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
"""
|
||||
import string
|
||||
|
||||
from xen.util import blkif
|
||||
from xen.xend.XendError import XendError, VmError
|
||||
from xen.xend import XendRoot
|
||||
from xen.xend.XendLogging import log
|
||||
from xen.xend import sxp
|
||||
from xen.xend import Blkctl
|
||||
from xen.xend.XendError import XendError, VmError
|
||||
from xen.xend.XendLogging import log
|
||||
from xen.util import blkif
|
||||
from xen.xend.XendRoot import get_component
|
||||
|
||||
import channel
|
||||
from controller import CtrlMsgRcvr, Dev, DevController
|
||||
@@ -206,7 +206,8 @@ class BlkDev(Dev):
|
||||
raise VmError('vbd: Device not found: %s' % self.dev)
|
||||
|
||||
try:
|
||||
self.backendDomain = int(sxp.child_value(config, 'backend', '0'))
|
||||
xd = get_component('xen.xend.XendDomain')
|
||||
self.backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
|
||||
except:
|
||||
raise XendError('invalid backend domain')
|
||||
|
||||
@@ -263,7 +264,7 @@ class BlkDev(Dev):
|
||||
|
||||
def check_mounted(self, name):
|
||||
mode = blkif.mount_mode(name)
|
||||
xd = XendRoot.get_component('xen.xend.XendDomain')
|
||||
xd = get_component('xen.xend.XendDomain')
|
||||
for vm in xd.list():
|
||||
ctrl = vm.getDeviceController(self.getType(), error=False)
|
||||
if (not ctrl): continue
|
||||
|
||||
@@ -102,7 +102,7 @@ class NetDev(Dev):
|
||||
else:
|
||||
#todo: Code below will fail on xend restart when backend is not domain 0.
|
||||
xd = get_component('xen.xend.XendDomain')
|
||||
self.backendDomain = int(xd.domain_lookup(sxp.child_value(config, 'backend', '0')).id)
|
||||
self.backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
|
||||
except:
|
||||
raise XendError('invalid backend domain')
|
||||
return self.config
|
||||
@@ -127,13 +127,13 @@ class NetDev(Dev):
|
||||
ipaddr = self._get_config_ipaddr(config)
|
||||
|
||||
xd = get_component('xen.xend.XendDomain')
|
||||
backendDomain = str(xd.domain_lookup(sxp.child_value(config, 'backend', '0')).id)
|
||||
backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
|
||||
|
||||
if (mac is not None) and (mac != self.mac):
|
||||
raise XendError("cannot change mac")
|
||||
if (be_mac is not None) and (be_mac != self.be_mac):
|
||||
raise XendError("cannot change backend mac")
|
||||
if (backendDomain is not None) and (backendDomain != str(self.backendDomain)):
|
||||
if (backendDomain is not None) and (backendDomain != self.backendDomain):
|
||||
raise XendError("cannot change backend")
|
||||
if (bridge is not None) and (bridge != self.bridge):
|
||||
changes['bridge'] = bridge
|
||||
|
||||